Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!uhog.mit.edu!bloom-beacon.mit.edu!spool.mu.edu!howland.reston.ans.net!news.sprintlink.net!noc.netcom.net!netcomsv!uu3news.netcom.com!netcomsv!uucp3.netcom.com!medicus!billf
From: billf@medicus.com (Bill Foote)
Subject: Re: A Question about Blocks
Message-ID: <1995Jun6.230323.7760@medicus.com>
Organization: Medicus Systems Corp.
References: <3qilug$bb7@ornews.intel.com> <1995Jun1.185657.9083@medicus.com> <ROGOFF.95Jun3202758@sccm.Stanford.EDU>
Date: Tue, 6 Jun 1995 23:03:23 GMT
Lines: 46

In article <ROGOFF.95Jun3202758@sccm.Stanford.EDU> rogoff@sccm.stanford.edu writes:
>In article <1995Jun1.185657.9083@medicus.com> billf@medicus.com (Bill Foote) writes:
>   On a more serious note, this is IMHO one of the advantages of a language
>   like Smallalk over, say, Eiffel or Sather.  With Eiffel you can at least
>   encapsulate your button-press action (to take that example) in a type-safe
>   way, but you do end up with the "code splattering" effect.  This isn't
>   an awful thing, it's just a bit annoying for simple actions.  I don't see
>   any reason why a bit of syntactic sugar couldn't take care of this in
>   a "static" language like Eiffel, but so far I haven't seen it done.
>
>When did you last look at Sather? The equivalent concept in Sather is called a 
>"bound routine". Point your web browser at 
>
>http://www.icsi.berkeley.edu/~gomes/sather-top.html
>
>and take a look at the tutorial documentation for an explanation of bound 
>routines; they provide exactly what you want. 

Close, but not quite.  Take, for example, the "make_or" example (in the
class MY_TEST near the end of 
http://www.icsi.berkeley.edu/~gomes/sather.html#SEC18).  In Sather, you're
forced to have the routine called "MY_TEST.stub_for_or" to compose the
two bound routines into one.  In Smalltalk, the "make_or" function
could be implemented thusly:

    makeOr: aBlock with: anotherBlock

        " Returns a block that when evaluated, returns the logical or of the
          result of evaluating the two blocks passed in as arguments.  This
          block will take one argument, and will supply it to each of the
          argument blocks.  "

        ^ [:arg | (aBlock value: arg) or: (anotherBlock value: arg) ]

In Sather, you need a "stub_for_or" method somewhere.  In Smalltalk,
you can use blocks to put the implementation of the block at the
point of creation, much like (lambda (args) (implementation)) in Lisp.

Note that I'm not saying that this is a horrible limitation or anything...
Just a bit of an annoyance every once in a while.

--
Bill Foote                | Adde parvum parvo magnus acervus ecrit.
billf@medicus.com         | [Add little to little and there will be a big pile]
Medicus Systems           |    -- Ovid, via Frederick P. Brooks, Jr.
Alameda, CA USA           |
