RE: Closures python,scheme,ruby

Discussion in 'Python' started by Robert Brewer, Jul 16, 2004.

  1. Bengt Richter wrote:
    > ...What if
    > x <= expr
    > meant evaluate expr and then
    > find x (as if to do a read access) and rebind it, whatever
    > name space it's found in?


    Sure, except overloading "less-than-or-equal-to" might be a small
    problem. ;)


    Robert Brewer
     
    Robert Brewer, Jul 16, 2004
    #1
    1. Advertising

  2. On Thu, 15 Jul 2004 20:49:18 -0700, "Robert Brewer" <> wrote:

    >Bengt Richter wrote:
    >> ...What if
    >> x <=3D expr
    >> meant evaluate expr and then
    >> find x (as if to do a read access) and rebind it, whatever=20
    >> name space it's found in?

    >
    >Sure, except overloading "less-than-or-equal-to" might be a small
    >problem. ;)
    >

    D'oh. I had it as
    x <- expr
    but then I wanted to bring in the assignment = and changed it
    without thinking *<8^P
    I guess <- is still available, if the tokenizer were made to
    look ahead to recognize it instead of the individual < and -
    so
    x <- expr
    wouldn't mean
    x < -expr
    ;-)
    Regards,
    Bengt Richter
     
    Bengt Richter, Jul 16, 2004
    #2
    1. Advertising

  3. Robert Brewer

    Sean Ross Guest

    "Bengt Richter" <> wrote in message
    news:cd7mvc$q61$0@216.39.172.122...
    > On Thu, 15 Jul 2004 20:49:18 -0700, "Robert Brewer" <>

    wrote:
    >
    > >Bengt Richter wrote:
    > >> ...What if
    > >> x <=3D expr
    > >> meant evaluate expr and then
    > >> find x (as if to do a read access) and rebind it, whatever=20
    > >> name space it's found in?

    > >
    > >Sure, except overloading "less-than-or-equal-to" might be a small
    > >problem. ;)
    > >

    > D'oh. I had it as
    > x <- expr
    > but then I wanted to bring in the assignment = and changed it
    > without thinking *<8^P
    > I guess <- is still available, if the tokenizer were made to
    > look ahead to recognize it instead of the individual < and -
    > so
    > x <- expr
    > wouldn't mean
    > x < -expr
    > ;-)
    > Regards,
    > Bengt Richter



    Or, perhaps 'x => expr' or 'x -> expr' or 'x := expr'?

    Read 'x is bound to expr', rather than 'expr is bound to x' (x <- expr).

    These, atleast, would avoid the less-than-negation confusion posed by
    '<-' and the overloading of '<='. But rather than using these to look-up
    and re-bind, I would think you would want to use them for the initial
    binding (or let statement) and retain '=' for the re-binding (or set/update
    statement). Io, for instance, does it this way - it uses ':=' for setSlot
    and
    '=' for updateSlot. If it were done the other way, then, should we wish to
    remain consistent in the appearance of re-binding operations, we
    would need to say 'a +=> b' or 'a +-> b' or 'a +:= b' instead of 'a += b'.

    No, thank you.

    On the other hand, there remain people who wish to be able to say

    if a = b:
    do_something()

    and

    while a = b:
    do_something()

    but others want to avoid the bug of confusing = with ==. Having '=>', '->'
    or ':=' as the re-binding operator would allow for this, e.g.

    while a => feed():
    do_something()

    or

    while a -> feed():
    do_something()

    or

    while a := feed():
    do_something()

    You would still need to bind 'a' initially (somewhere), however - unless
    you took the above to mean bind 'a', locally, to a value from 'feed()' and
    keep binding (not re-binding) 'a', locally, to new values from feed() until
    feed() is exhausted. That would limit some of the utility of the construct
    though, since it would not allow you to iteratively re-bind a variable from
    another scope (you would only ever be creating a new local variable
    'a').
     
    Sean Ross, Jul 16, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kasper B. Graversen

    Closures in python

    Kasper B. Graversen, Sep 18, 2003, in forum: Python
    Replies:
    11
    Views:
    750
    David Eppstein
    Sep 21, 2003
  2. paolo veronelli

    Closures python,scheme,ruby

    paolo veronelli, Jul 12, 2004, in forum: Python
    Replies:
    5
    Views:
    1,043
    Jacek Generowicz
    Jul 16, 2004
  3. Karl Kofnarson

    What are python closures realy like?

    Karl Kofnarson, Dec 1, 2006, in forum: Python
    Replies:
    16
    Views:
    488
    Roy Smith
    Dec 12, 2006
  4. treble54

    Closures / Blocks in Python

    treble54, Jul 24, 2007, in forum: Python
    Replies:
    10
    Views:
    822
    Gabriel Genellina
    Jul 26, 2007
  5. zuzu
    Replies:
    12
    Views:
    306
    Florian Gross
    Aug 27, 2004
Loading...

Share This Page