[Grace-core] collections interface for new classes
James Noble
kjx at ecs.vuw.ac.nz
Sat Dec 12 23:25:18 PST 2015
>> 1. take the varargs versions back to single elements,
>> leave the “All” versions taking collections
>>
>>> c.add “x”
>>> c.addFirst “x”
>>> c.addLast “x”
>>>
>>> c.addAll [ “x”, “y” ]
>>> c.addAllFirst [ “x”, “y” ]
>
> Yes, this is what we should do.
Ok
>> * amg (Andrew’s minigrace) has a few methods in the AST and parser
> I inherited two of these from Michael. They should be removed and replaced by methods with meaningful names. I added method new(*values) scope(s) so that I could initialize the scope argument and then forward to one t=of the others; this was me being lazy.
sounds like this isn’t important. whether you update them or not is up to you:
I guess it depends whether you think it’s work moving mg to what I think of as the “0.8” language or not
(no super, no varargs, etc)
actually with only a few varargs mehtods & only 45? super calls modifying the code to run on 0.8 may not be too hard.
modifying mg to compile 0.8 may be harder…
>> PPS if we’re allowed “min” and “max” surely we are allowed “seq” as well?
>>
>> PPPS if we add “min” and “max” into collections, there’s average, and sum, and …
>> although here I think I’d be very happy to have a trait that mixed this in to the collections library elsewhere
>
> The problem with min and max is that these work only for total orders, and not all collections have total orders. Smalltalk leaves this up to the programmer. Is there a stringily-typed solution that is as convenient, but more foolproof?
well I wondered about some kind of method guards
class list<T> {
method max where T <: Numeric { …
//can assume T is numberic or something
but it seems a bit “Haskell” to me
> (Addition on strings is spelled ++, while addition on numbers is spelled +.
I guess that is something else we could look at…
>>
>> PS andrew - which is the best current version of collections to work on?
>
> I just checked-in a new version to apblack/minigrace, and have just this minute push it to gracelang/minigrace ( I was waiting for the Travis tests to run green.)
OK I think I’m looking at gracelang/minigrace, ../collectionsPrelude, and e.g. …/modules
I presume you’re happy for me to look at this - doing (rough) - kernan versions
rather than take that on yourself? if you’d rather do it, that’s fine by me and I
can do other stuff
J
More information about the Grace-core
mailing list