[Edu-sig] Smalltalk syntax benefits

John Zelle john.zelle at wartburg.edu
Thu Aug 10 19:23:27 CEST 2006


On Thursday 10 August 2006 10:24 am, Paul D. Fernhout wrote:

> What about constructors like
>    "Line origin: 10 @ 10 angle: 35 degrees distance: 10 mm"
> (which is easy to have in Smalltalk syntax) and so on? And I bet you can
> read what it means not even knowing Smalltalk. Would you rather read:
>    "Line(10, 10, 35, 10)"?
> Or at best:
>    "Line(Point(10, 10), 35, 10)"?
> Which is clearer? I think this goes beyond my bias as being experienced
> using Smalltalk system keyword syntax.
>
> Not to be too hard on you or Kirby, but I think it is easy to not see the
> value of the unfamiliar, and there is a lot functional foo() syntax makes
> difficult and awkward looking (Lisp, a Python ancestor in a sense, has a
> bit of this problem too).
>
> Again, just because Smalltalk has this and Python does not does not mean
> I'm saying "use Smalltalk". I'm just saying, how can Python get this
> feature? Maybe it can't. Then my next thing is, can the two syntaxes live
> side by side -- a possible area for exploration.
>

Just so we're all clear on this, you _can_ use keyword arguments in Python. So 
your constructor could just as well be:

Line(origin=Point(10,10), angle_in_degrees=35, distance_in_mm=10)

Of course, Python only allows this, it does not force you to use such a style. 
To me this is at least as descriptive as the SmallTalk version. Perhaps it 
says something that Python allows this form, but it does not seem to be used 
often in practice, except when there are large numbers of mostly 
default-valued parameters. Perhaps the reason is that the keyword form 
_requires_ more typing (lowering productivity) and the labeling of the 
arguments (revealing formal parameter names) is pretty much provided by any 
IDE that is worth its salt. 

--John

-- 
John M. Zelle, Ph.D.             Wartburg College
Professor of Computer Science    Waverly, IA     
john.zelle at wartburg.edu          (319) 352-8360  


More information about the Edu-sig mailing list