LAMBDA IS IT USELESS?

Bengt Richter bokr at accessone.com
Sun Jul 15 01:10:58 CEST 2001


On Sat, 14 Jul 2001 19:15:37 GMT, Ben Wolfson <rumjuggler at cryptarchy.org> wrote:

>On Sat, 14 Jul 2001 17:55:25 GMT, bokr at accessone.com (Bengt Richter) wrote:
>
>>From the grammar, we have
>>    funcdef: 'def' NAME parameters ':' suite
>>where
>>    parameters: '(' [varargslist] ')'
>>and
>>    lambdef: 'lambda' [varargslist] ':' test
>>
>>So what would happen if that last "test" were
>>changed to "suite" ? If the end of "suite" is
>>well defined, why would there be a problem?
>
>If that's *all* you do, this happens:
>
>harper:~/tmp/Python-2.1.1c1> ./python
>'import site' failed; use -v for traceback
>Python 2.1.1c1 (#1, Jul 14 2001, 14:09:38)
>[GCC 2.95.2 19991024 (release)] on sunos5
>Type "copyright", "credits" or "license" for more information.
>>>> t = lambda a:
>...     if a == 1:
>...             print 'hi'
>...     else:
>...             print 'bye'
>...
>>>> t
><function <lambda> at be4ac>
>>>> t(1)
>hi
>Bus error
>harper:~/tmp/Python-2.1.1c1>
>
Well, gee, it printed "hi," so it's just a SMOD[1] to get there ;-))

Seriously, I don't know how the grammar file plays into rebuilding the interpreter,
but I can see it doesn't define actions like a flex grammar, so even that
level of change is not going to be possible with just a grammar file change.

So something's probably still being handed a "suite" in some form and still
trying to interpret it as "test".

I guess we should take the note at the top of the grammar file seriously ;-)
"""
# Note:  Changing the grammar specified in this file will most likely
#        require corresponding changes in the parser module
#        (../Modules/parsermodule.c).  If you can't make the changes to
#        that module yourself, please co-ordinate the required changes
#        with someone who can; ask around on python-dev for help.  Fred
#        Drake <fdrake at acm.org> will probably be listening there.
"""

Looking at parsermodule.c, I can see it will take a bit of pondering ;-)

It is kind of tantalizing though. Makes me want to get set up to do experiments
like you apparently did. Wish there were more hours in a day ;-)


[1] Simple Matter Of Debugging ;-)



More information about the Python-list mailing list