Alex Martelli wrote: > M Jared Finder <[EMAIL PROTECTED]> wrote: > ... >> Your reasoning, taken to the extreme, implies that an assembly language, >> by virtue of having the fewest constructs, is the best designed language > > Except that the major premise is faulty! Try e.g. > <http://docs.sun.com/app/docs/doc/817-5477/6mkuavhrf#hic> and count the > number of distinct instructions -- general purpose, floating point, > SIMD, MMX, SSE, SSE2, OS support... there's *hundreds*, each with its > own rules as to what operand(s) are allowed plus variants such as (e.g.) > cmovbe{w,l,q} for "conditional move if below or equal" for word, long, > quadword (no byte variant) -- but e.g cmpxchg{b,w,l,q} DOES have a byte > variant too, while setbe for "set if below or equal" ONLY has a byte > variant, etc, etc -- endless memorization;-). > > When you set up your strawman arguments, try to have at least ONE of the > premises appear sensible, will you?-) > > I never argued against keeping languages at a high level, of course > (that's why your so utterly unfounded argument would be a "strawman" > even if it WAS better founded;-). > >> prone, code. I think the advantages of anonymous functions: > ... >> e) making the language simpler to implement > > Adding one construct (e.g., in Python, having both def and lambda with > vast semantic overlap, rather than just one) cannot "make the language > simpler to implement" -- no doubt this kind of "reasoning" (?) is what > ended up making the instruction-set architecture of the dominant > families of CPUs so bizarre, intricate, and abstruse!-)
It sure can. First, let's cover the cost. I'll be measuring everything in terms of lines of code, with the assumption that the code has been kept readable. Here's an implementation of lambda (anonymous functions) in Lisp based on flet (lexically scoped functions): (defmacro lambda (args &rest body) (let ((name (gensym))) `(flet ((,name ,args ,@body)) (function ,name)))) That's three lines of code to implement. An almost trivial amount. Now by using anonymous functions, you can implement many other language level features simpler. Looping can be made into a regular function call. Branching can be made into a regular function call. Defining virtual functions can be made into a regular function call. Anything that deals with code blocks can be made into a regular function call. By removing the special syntax and semantics from these language level features and making them just pain old function calls, you can reuse the same evaluator, optimizer, code parser, introspector, and other code analyzing parts of your language for these (no longer) special constructs. That's a HUGE savings, well over 100 lines of code. Net simplification, at least 97 lines of code. For a concrete example of this in action, see Smalltalk. -- MJF -- http://mail.python.org/mailman/listinfo/python-list