Re: we need official libs : Swap

new topic     » topic index » view thread      » older message » newer message

Roderick Jackson wrote:

> I think I've decided. This construct is a Bad Thing.
> Ambiguity and exceptions abound concerning subscripts,
> slices, off-sized sequences, and multiple instances of
> a variable.

I disagree. Implementation removes the ambiguity - it just may not work the
way you expected.

This mechanism is basically a way of getting around the fact that you can't
pass by reference is Euphoria. This constraint often leads to unclear code,
such as (actual example):

   pt1 = mapToParent( self, x1, y1 )
   pt2 = mapToParent( self, x2, y2 )
   draw_line( pt1[X], pt1[Y], pt2[X], pt2[Y] )

Compare that with:

   { x1, y1 } = mapToParent( self, x1, y1 )
   { x2, y2 } = mapToParent( self, x2, y2 )
   drawLine( x1, y1, x2, y2 )

I consider the second version to be much more readable.

-- David Cuny

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu