Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Mexpr Scheme

Name: Anonymous 2012-10-27 11:11

Hello /prog/.
I'm making my own Scheme-like language with blackjack and hookers. It slowly became nearly as ugly as common lisp, so I decided to look through original McCarthy papers and implemented alternative syntax: http://pastebin.com/fiJKvvMY
New syntax causes new problems. The biggest problem bugging me now is method call syntax. Originally method call looked like (method object ...) where method is an expression which returns atom or an atom itself. This allows to choose method at run-time.
New syntax requires to write object #method[...] with method explicitly specified at compile-time. That looks like a problem to me.
Any ideas how to improve syntax?

Name: Anonymous 2012-10-27 11:46

>>1
I remember this. I thought it would turn out ugly. Just use clos style dude! They mix wonderfully with the higher order functions.

But if you want to go with method invocations, you can think about the parse tree for the conventional languages:


obj.method1(arg1, arg2).method2(arg3)
((. ((. obj method1) arg1 arg2) method2) arg3)


Or you can think of obj as a function that takes symbols and returns functions


((((obj method1) arg1 arg2) method2) arg3)


Or you can think of obj as a function that takes a list of args where the first arg is the method to invoke, and the rest of the args are the arguments to the method:


((obj method1 arg1 arg2) method2 arg3)


Or you can just use clos style.


(method2 (method1 obj arg1 arg2) arg3)


The #method syntactic sugar works too, but you should just let it be syntactic sugar for one of the representations above so that you can still use the object system from macros in a painless way.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List