gracelang / minigrace

Self-hosting compiler for the Grace programming language
39 stars 22 forks source link

ExtendedLineup should go away; replace by List #276

Closed apblack closed 5 years ago

apblack commented 5 years ago

The #pragma ExtendedLineups causes the [...] notation to create a mutable object that is like a list — except that it is missing several of the list methods:

- addAllFirst(_)
- sort
- removeAll(_)
- removeAll(_)ifAbsent(_)
- sorted 
- remove(_)ifAbsent(_)
- sortBy(_)
- removeAt(_)
- sortedBy(_)
- indexOf(_)
- values
- indexOf(_)ifAbsent(_)

The reason for ExtendedLinups is to improve the speed of the compiler. Otherwise, we should just use lists. For speed, we should just add these missing methods toExtendedLinupand re-implementlistto use them. If we don't need the speed, we should get rid of ExtendedLineup and use the version oflist` implemented in collectionPrelude.grace.

It's not reasonable to keep both list and ExtendedLineup in their present form.

_t155_primitiveListtest.grace tests ExtendedLineup; _t150_collectiontest.grace tests list.

apblack commented 5 years ago

The most recent version of collectionPrelude.grace to contain the native "js" code version of lists was c863757; it was removed in the following commit, fc13dbb.

This version should be restored to a separate module, and benchmarked, to see if it is worth reinstating.

kjx commented 5 years ago

The #pragma ExtendedLineups causes the [...] notation to create a mutable object that is like a list

this is kind of horrid, especially if someone tried to run the compiler on something where lineups weren't mutable. Especially if you want that, isn't it better to just write list? or even [].mutable where the .mutable is a no-op and is dropped by the compiler when applied to literals?

apblack commented 5 years ago

What is "kind of horrid"? If you are saying that ExtendedLinups are horrid, you will find furious agreement here, which is why this issue is here: to remind us to make them go away.

Or are you saying that making them go away and replacing them by lists is horrid?

kjx commented 5 years ago

They're horrid and yes should be got rid of.
Any code using the "[ ]" syntax for something mutable can't run on any other version of Grace, and I can't see how that can be fixed with a library (unless "[ ]" is somehow definable)

Inasmuch as I write code, I've barely ever used that notation and haven't missed it.

apblack commented 5 years ago

They are gone, as of commit ca6ecac