On Thu, 08 May 2008, Alex Strickland wrote:

Hi Alex,

> >none of the above can be translated by Clipper. Unfortunately we
> >inherited from xHarbour WITH OBJECT syntax where :<msg> is used.
> >It causes that I couldn't replicate exact Clipper behavior because
> >such simple code will not work:
> >   WITH OBJECT errorNew()
> >      ? :canRetry
> >   END
> >But this introduce some incompatibilities.
> Why not drop it in Harbour?
> Are there people out there who would be greatly inconvenienced? If so, 
> perhaps some alternative like:
>     WITH OBJECT errorNew()
>        ? -:canRetry
>     END
> which uses the hyphen as a kind of visual placeholder.

- is also not a good choice for other reasons. The visual placeholder
should have the same properties as identifier for PP which should recognize
it with message as separated expression, f.e. in this code:

   #tran a( <x> <y> ) => qout( #<x>, #<y> )
   a( abc def )
   a( abc -:msg )

a( abc -:msg ) is not translated because for Clipper's and Harbour's PPs
abc -:msg is a single expression. It means that other things will not work
as expected.
Maybe we should think what such construction like WITH OBJECT / END
gives programmer. In fact it introduce only one feature. Temporary
stack level variables which does not need declaration. It's very usable
mechanism when I have to define some multi line PP commands. I can use
this variable to store data collected from each line. Because it's
unnamed variable then it's even possible to use it in nested constructions.
For the same reason it's also usable when I do not want / cannot declare
variable for result of some calculations, f.e.:

   with object UPPER( s )
      ? :__withObject()
      fwrite( h, :__withObject(), len( :__withObject() )
   endwith

Maybe it will be more elegant giving also better functionality if we
add explicit support for temporary variables, f.e.:

   with var <var1> [ := <exp1> ] [, <varN> := [ <expN> ] ]
   endvar

Such construction uses explicit variable names so it does not badly
interact with PP. Clipper's PP does not accept '~' at all so it also
can be used by I would like to reserve this character for some new
operators if it will be necessary to introduce them. Anyhow now I do
not want to touch it. There is a lot of different things waiting for
unblocked repository after 1.0.

best regards,
Przemek
_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to