On Mon, Aug 16, 2010 at 18:37, David Chisnall wrote: > On 16 Aug 2010, at 17:14, Truls Becken wrote: > >> I actually did think about implementing a Nu parser for Language Kit, but >> concluded that it is >> not possible. The reason is that with an expression such as "(document >> library)" there is no >> way to know at compile time whether "document" is a function with one >> argument or an >> object receiving the message "library". Nu does this at runtime, by asking >> document to >> evalWithArguments:context: every time that piece of the program is executed. > > That's not necessarily a problem. For example, we could always implement > evalWithArguments:context: in categories on NSBlock, BlockClosure, and > NSObject to get > the same effect, although it would still come with a performance penalty.
True, and the problem is actually only with unary expressions because (document a b) has to be a function call and (document foo:bar) has to be a message send. > We could maybe do some static analysis or use type feedback to try to > optimise it, or maybe just > insert a compile-time test on each Nu expression to see whether the receiver > is function-object. Yes, and all of this because the grammer is ambiguous. I do realize that this also brings some expressive power, but I don't think it is actively used in Nu. E.g. like in Paul Graham's lisp dialect at http://arclanguage.com, collections could behave as functions on key values; (numbers 'foo) -> 42 or ("wombat" 2) -> "m". I would very much prefer that it was obvious whether something was a function or a message send, however. -Truls _______________________________________________ Etoile-discuss mailing list [email protected] https://mail.gna.org/listinfo/etoile-discuss
