[Grace-core] Fwd: Query on built-in objects

Andrew P. Black black at cs.pdx.edu
Mon Jun 18 22:28:58 PDT 2012


So Smita's question is: why do Numbers have a ++ method (which converts to string and then concatenates), while Booleans don't have one.

Clearly we should be consistent, but I'm wondering which is best.  I think that it's quite reasonable to use ++ to mean concatenation of any sequence, such as a list of numbers ... so automatic conversion to string seems wrong.

	Andrew

Begin forwarded message:

> Professor Black,
> 
> I found an interesting behavior in Grace, while working on Strings, Numbers and Boolean built-in objects.
> 
> Concatenation of Number and String works fine with ++ operator, but throws an error when I tried the same with Boolean and Number, and Boolean and String.
> 
> Example: 1 - Boolean and Number/String
> 
> var a:= true
> var b:= " smita"
> print (a ++ b)
> 
> Error around line 3: Method lookup error: no ++ in Boolean.
> Called Boolean.++ (3)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailhost.cecs.pdx.edu/mailman/private/grace-core/attachments/20120618/7a206564/attachment.html>


More information about the Grace-core mailing list