On Sunday 29 June 2008 23:32:03 Slava Pestov wrote:
> I still want to redesign the proposed multi-method syntax to avoid the | in
> stack effects, after a recent epiphany regarding the evilness of complex
> lexing rules. Any suggestions there? This seems ugly:
> : nth ( { i integer } { a array } -- elt ) ... ;
Was the complex lexing rules issue bad enough such that you won't consider the
parmeter:type
style at all? I.e. have you definately given up on that idea?
I don't think you're going to get around the fact that this is the best syntax
for the problem at hand.
Another style similar to old school C is where you put the types in a separate
place:
: nth ( i seq -- elt )
...
... ; ( integer sequence -- object )
I.e. the type annotation goes in a separate place.
I would have thought that it would be pretty easy to expand:
a:object
into some canonical form like
{ a object }
inside of an effect.
I agree that inter-token level syntax should be used sparingly. I strongly
believe this is one of the valid cases. I feel the same way about typed
slots. The argument was made for typed tuple slots occuring relatively
infrequently; no such argument can be made for words.
Thinking about syntax, when you employ bounded delimiters such as { and },
they imply that an arbitrary number of items may be enclosed. Here, you are
trying to denote at most two elements; parameter and type. So this is
syntactic overkill. To denote a pair, a single separator will suffice.
For better or worse, people will want to do token level syntax. It would be
good to have this ability demonstrated in at least part of the core language.
But you asked for alternatives. Here's one:
: nth ( i | integer seq | sequence -- elt | object )
That doesn't break the whitespace rule. But maybe it looks funny. Commas can
be added to add some separation hint:
: nth ( i | integer , seq | sequence -- elt | object )
This is still the best:
: nth ( i:integer seq:sequence -- elt )
Ed
-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk