On 26/12/2012, at 5:01 PM, Dobes Vandermeer wrote:

> I think the #true thing is not bad.  It may be worth considering treating 
> special cases like that as if "true" were a boolean literal rather than an 
> identifier, and doesn't require a parameter.  But that said, #true isn't that 
> bad.  In LISP they always write #t and it doesn't bother people much.
> 
> I've been playing around with Stratego/XT and they decided to use a rule "if 
> it's undefined, bind it - if it has a value already, match it"  It's bitten 
> me many times where I thought I was binding a new variable but actually there 
> was already a variable bound with that name so it tried to match instead and 
> failed.  So ... that's an error-prone path to avoid despite allowing even 
> less syntax.  Having it syntactically clear whether one is binding or 
> matching is definitely better for readability.

Yeah. And, somewhat generalised, your argument applies to other things in Felix
too. Felix uses quite a lot of sugar and magic and I'm not sure it is so sweet
as when I first implemented it.

The canonical example is: 

        var x = 1,2,3;

That's an array. originally you had to write:

        var x = [< 1,2,3 >];

to convert a tuple to an array. Another more subtle one is:

        fun add: int * int -> int = "$1+$2";

Yep, add looks like a function. But it isn't. Its a macro.
Arguments are usually lazily evaluated, that is, they're
just plugged in to $1 and $2. 

however if you use it like a closure:

        var f = add of (int * int);

then the arguments are eagerly evaluated.
How can Felix make a macro into a closure?
Answer: the compiler notices and generates a wrapper:

        fun closure (x:int, y:int) => add (x,y);

which really is a function.

And .. it looks like the function takes a tuple argument.

But it doesn't. It takes two separate arguments.
So if you call it like:

        var x = 1,2;
        var y = add x;

it works, but only because Felix unpacks the tuple.

A lot of the "magic" is justified in terms of saying Felix is a scripting 
language.
We cannot afford to be too precise, or we'd clutter code with a whole lot
of structural conversions with no semantic importance to the user.

ATS is a more precise language. Actually I quite like it because of that.
I'm thinking to "undo" some of the magic in Felix, to make it a bit
more "deterministic". 

Also to lift some of the magic out of the compiler into the library.
One of these is operator dot (.). I am close to the point where I can
probably say:

        operator dot is just reverse application

And when I can say that, I can throw out all the hacks in the
compiler that first do field check then reverse application,
and just put operator dot in the library. (At the moment

        structure-value . field

does lookup first in the structure definition before trying

        field structure-value

by the reverse application rule: I cannot tell the compiler to do this
in the library at the moment).


--
john skaller
skal...@users.sourceforge.net
http://felix-lang.org




------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to