ajwang / groovypptest

Automatically exported from code.google.com/p/groovypptest
0 stars 0 forks source link

Add functional Map structures #348

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Groovy++ has FList, that's great. I'd suggest to add more functional immutable 
structure-sharing data structures, e.g. maps. Such FMap's put would return 
another FMap. I can think of at least three different implementations: hash 
map, sorted map and (if needed at all) the simplest one - a map over an 
FList<Pair<Key,Value>>. That would be very useful for writing bugless pure code.

Original issue reported on code.google.com by gromop...@gmail.com on 11 Mar 2011 at 10:04

GoogleCodeExporter commented 8 years ago
There is also FHashMap & FVector

Original comment by alex.tka...@gmail.com on 11 Mar 2011 at 10:10

GoogleCodeExporter commented 8 years ago
Wow, didn't notice that! Anyway a sorted variant would be useful.

Original comment by gromop...@gmail.com on 11 Mar 2011 at 10:19

GoogleCodeExporter commented 8 years ago
And a bit more concise syntax that "FHashMap map = FHashMap.empty" would be 
nice, although I have no idea how to do that.

Original comment by gromop...@gmail.com on 11 Mar 2011 at 10:23

GoogleCodeExporter commented 8 years ago
Exact syntax is 

def map = FHashMap.emptyMap

I can't imagine anything better except introducing some syntax for factory 
methods, which I have no idea how to do.

Maybe something like 

static FHashMap factory () {...} 

and then you can use it as constructor. Not sure if it worth an effort

Regarding sorted map - contributions are welcome.

Original comment by alex.tka...@gmail.com on 11 Mar 2011 at 10:36

GoogleCodeExporter commented 8 years ago
I'd like to use FMaps as fields, where def is out of the question. OTOH the 
right-hand side is also out of the question since the fields are final, so 
let's forget about that issue.  I agree that this alone is not serious enough 
to care about factory methods.

Original comment by gromop...@gmail.com on 11 Mar 2011 at 10:41

GoogleCodeExporter commented 8 years ago

Original comment by alex.tka...@gmail.com on 11 Mar 2011 at 10:49