Author Topic: This is what happens when I get bored.  (Read 7171 times)

0 Members and 1 Guest are viewing this topic.

Offline Kawa

This is what happens when I get bored.
« on: September 21, 2016, 04:39:50 PM »
I not only make mockups... but I implement them!

There used to be an image here, but it's gone.
« Last Edit: October 24, 2016, 02:11:06 PM by Kawa »



Offline troflip

Re: This is what happens when I get bored.
« Reply #1 on: September 21, 2016, 05:00:39 PM »
I'm not sure what that is, but... nice artwork!
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline Kawa

Re: This is what happens when I get bored.
« Reply #2 on: September 21, 2016, 05:18:49 PM »
Clearly that's a column-based window manager with a lisp prompt, from which I've opened another column and a document viewer, whose contents I could've loaded from an external file (which would also be a Lisp s-expression) but I decided to be silly and do it inline.

The artwork isn't mine.

Offline troflip

Re: This is what happens when I get bored.
« Reply #3 on: September 21, 2016, 06:18:50 PM »
of course... how did I not realize that..
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline Kawa

Re: This is what happens when I get bored.
« Reply #4 on: September 21, 2016, 07:37:55 PM »
The sarcasm is palpable from both sides.

I hold you responsible btw for (re)getting me into Lisp.

Offline lskovlun

Re: This is what happens when I get bored.
« Reply #5 on: September 21, 2016, 07:49:48 PM »
The sarcasm is palpable from both sides.

I hold you responsible btw for (re)getting me into Lisp.
Blame me instead for dissuading various people from going ahead with a C/C++ syntax way back when (and insisting on the use of the original class hierarchy; although this might have happened sooner or later in any case). Brian's take on the SCI syntax was not perfect, but it led us in this direction.

Offline Kawa

Re: This is what happens when I get bored.
« Reply #6 on: September 21, 2016, 07:54:56 PM »
And I for one have had more success implementing not only an s-expr parser but a functional interpreter than I could hope to get for a C-like so there's that too.

Also, after two days of struggling I still would rather avoid WPF for any future endeavor... and WPF is what you see in that screenshot :(

Offline OmerMor

Re: This is what happens when I get bored.
« Reply #7 on: September 22, 2016, 03:04:50 AM »
Blame me instead for dissuading various people from going ahead with a C/C++ syntax way back when (and insisting on the use of the original class hierarchy; although this might have happened sooner or later in any case). Brian's take on the SCI syntax was not perfect, but it led us in this direction.

I didn't you know you influenced Brian to do that Lars! Thanks!  :)
Where did the information about the original SCI syntax come from anyway?

Offline lskovlun

Re: This is what happens when I get bored.
« Reply #8 on: September 22, 2016, 11:23:10 PM »
I didn't you know you influenced Brian to do that Lars! Thanks!  :)
Where did the information about the original SCI syntax come from anyway?
Well, we did have a few source samples available at the time (and also an experimental conversion of SQ3 script 0 to a C++ sort of language). As for the class hierarchy - this was at the time when the compiler in SCI Studio had just been released. Christoph had ported it to Linux. There was as I recall one demo program available which used a modal loop and Display/DrawCel... which is of course not how the animation system in SCI is best used. My work on FreeSCI meant I was familiar with the class hierarchy at this point, and I set out to incorporate it in the easiest way possible. I wrote a tool which would take a game and create .SCO files from the scripts. This made it possible for SCI Studio to link my code with the class hierarchy of a game (I used PQ2). The code was added to the base game via patches. It was quite clunky, and once Brian started work on the template game, I dropped the project and never released it. Having a template game with source was of course much better, I only needed to get people on board.  :)

Offline Kawa

Re: This is what happens when I get bored.
« Reply #9 on: October 08, 2016, 02:03:10 PM »
Related to the actual intended topic of Felinese lisp machines, I've had a close look at how Common Lisp does objects and retched. Call me tainted by SCI but I think the SCI object notation is much nicer.

Code: [Select]
(defclass rectangle()
  (
    (height :accessor rectangle-height :initarg :height)
    (width: :accessor rectangle-width :initarg :width)
  )
)

(set rect (make-instance 'rectangle :height 3 :width 7))
(rectangle-height rect) ==> 3
(setf (rectangle-height rect) 4)

(defmethod area ((figure rectangle))
  (* (rectangle-height figure) (rectangle-width figure))
)
(area rect) => 28
Seriously? Defining class methods outside of the class? I'd much rather try to make sense of this SCI-inspired equivalent:
Code: [Select]
(class rectangle
  (properties
    height 1 ; default to unit rectangle
    width 1
  )
  (method area () ; blank parameter list
    (* height width)
  )
)

(set rect (new rectangle (height 3 width 7)))
(rect height) => 3
(rect height 4)
(rect area) => 28
I have an implementation in mind for this already.

In less-related news, this is what happens when I get bored and have Kamen Rider Ex-Aid on the brain:

Offline lance.ewing

Re: This is what happens when I get bored.
« Reply #10 on: October 08, 2016, 05:46:58 PM »
Although learning Lisp is on my "list" so to speak, I still really admire the SCI syntax. I've been tempted many a time to work on a SCI compiler that is the pure SCI language, separate from the adventure game aspects, since I think it might be popular as a programming language in it's own right. - Right?

Who is that grey feline girl by the way? You'll have to introduce me.

Offline Kawa

Re: This is what happens when I get bored.
« Reply #11 on: October 08, 2016, 06:25:17 PM »
That's Ilira, the player character from my SCI game project.

It might actually not be too difficult to make an SCI-style standalone Lisp dialect. I feel like the most difficult thing for me could be array notation, the whole [] thing.

To elaborate: in Lisp you basically have lists and atoms (everything that's not a list). A list is usually saved as a chain of cons cells, like a linked list in other environments. So the expression (1 2 3) is stored in memory as a cons with car 1 and the cdr a pointer to a cons with car 2, pointing to a cons with car 3, cdr null. You have your forms, which are lists where the first element is a symbol naming a function. And finally, you have the functions car and cdr, which return the first item in a list and the rest of the list respectively. So (car '(1 2 3)) returns 1 and (cdr '(1 2 3)) returns (2 3). Logically then you can have a cadr function, which is basically (car (cdr X)).

Also, code is data and data can be code. That's what the ' in those examples was for, to suppress the attempt to read (1 2 3) as a function call. Well, close enough to that.

There are no arrays in this definition, you might notice. Each dialect has its own take on how those work, if they have arrays at all. Common Lisp has #(1 2 3) indicate an array literal, while Clojure and Emacs Lisp use [1 2 3]. And you don't look up values the way you would in other languages: assuming we have a variable A that's an array with 1 2 and 3, you'd get the second item with (elt A 1) in CL and Emacs, but with (nth A 1) in Clojure, and with (vector-ref A 1) in Racket. And that's ignoring the array operations that they simply don't all support!

So yeah, allowing an array lookup with [A 1] like in SCI might be tricky.

Actually, now that I've typed that, I'm thinking reader macros. The ' character doesn't mean "don't evaluate the next bit", it means "pretend the next bit is in a (quote ?) form" -- '(1 2 3) is parsed as (quote (1 2 3)), and quote basically just returns its arguments untouched. As such, you could have a reader macro for the [ character to parse as (elt ?). Now you just need a way to distinguish between lookups and definitions.

Offline Kawa

Re: This is what happens when I get bored.
« Reply #12 on: October 10, 2016, 09:50:45 AM »
Update regarding SCI-syntax array lookups:

In Common Lisp, you use (elt A 1) (assuming the same array as before) to get the 2. You uses (setf (elt A 1) 4) to make it [1 4 3]. Compare and contrast this with SCI's [A 1] to get and (= [A 1] 4) to set.

Yesterday, in my personal interpreter, I added [ as described, so I can do [A 1] to get the 2. But since I write this in C# with safeties on, how do I allow setting it? Ignoring how you want to call the set function, my elt simply returns the indicated array value! So last night I came up with a silly little trick: I have a setf object field in my stack frame type, and setf-able functions like elt set that field to some particular object to give setf something to work with. Thus, (elt A 1) not only returns a 2, which setf ignores, but it also sets the setf field to a tuple <A, 2>, giving setf something to detect and work with. The other things it could be made to work with are cons cells and maybe strings.

(set A #(1 2 3))
(prin1 A) ;=> #(1 2 3)
(setf [A 1] 4) ;parsed as (setf (elt A 1) 4)
(prin1 A) ;=> #(1 4 3)

Offline Kawa

Re: This is what happens when I get bored.
« Reply #13 on: October 17, 2016, 09:37:18 AM »
Oh no, progress! Remember that rectangle class?

(class rectangle
  (properties
    height 1
    width 1
  )
  (method area ()
    (* height width)
  )
)
(= myRect (new rectangle height 3 width 7)) ; doesn't quite work yet -- height and width aren't initialized and stay 1.
(myRect (width 4) (height 2) (area)) ; works -- returns 8


That final line is a bit different from the original idea, but I like it like this.

I went with a dispatcher function -- new ultimately returns a function (bound to myRect) that runs through each passed form, doing the lookups, gets, sets, and invocations.

Not done yet: subclassing


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.121 seconds with 23 queries.