[Grace-core] Fwd: Query on built-in objects
James Noble
kjx at ecs.vuw.ac.nz
Mon Jun 18 23:31:24 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.
good question. We haven't started systematically on library design
(a good reason to get modules & annotations (& generics) done...)
> 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.
yes, makes sense to me.
Probably not using plain "+" for concatenation is best, although I saw a study somewhere
(http://www.springerlink.com/content/1537m70w13591624/, pg91)
saying that "fire" + "fox" was quite understandable as yeilding "firefox"
(for various reasons, this is about the only result from that study I really trust)
J
> 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)
>
> _______________________________________________
> Grace-core mailing list
> Grace-core at cecs.pdx.edu
> https://mailhost.cecs.pdx.edu/mailman/listinfo/grace-core
More information about the Grace-core
mailing list