new map type (Re: Ann: SWI-Prolog 7.1.0)
Alan Baljeu <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <[email protected]> |
- The system introduces `maps' as primary citizens. Maps are
collections of key-value pairs, optionally typed. Maps are
supported by read and write. The syntax is
type{key1:value1, key2:value2, ...}
This will be very nice. Incidentally in my project I have compiled
names into indices in class-generated objects, so I won't be needing
the map for that.
Keys in a map can be addressed using the functional notation
Map.Key. User functions on maps can be accessed as Map.Compound
(e.g., Vector.multiply(V2)).
When you say functional notation, I am a little leary of confusion
regarding when something gets applied:
plus(Map.key, 2,3) does this work?
plus(Map.Key, 2,3) does this work? Does it backtrack if Key is non-ground?
The notation Vector.multiply(V2) *might* be okay, but I'm skeptical. I
suppose this implies:
Vector .multiply(V2) % good
Vector. multiply(V2) % error
But in any event, is there a meaning to this example, or is it a bad choice
of words? The only thing I can think of is not very Prolog-like:
V2 = V1.scalar_multiply(3), or
Number = Vector.dotProduct(V2)
Will/do other systems support maps?
Alan Baljeu