[Grace-core] Fwd: Query on built-in objects
Kim Bruce
kim at cs.pomona.edu
Mon Jun 18 23:56:53 PDT 2012
I think we want to allow students to write
print (7)
rather than have to write
print "{7}"
or
print (7.asString)
This leads me to believe it should take an argument with type {asString -> String}, where asString on Strings is just the identity function. However, I'd be happy to hear arguments to the contrary.
Kim
On Jun 18, 2012, at 11:31 PM, James Noble wrote:
>> 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
>
> _______________________________________________
> 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