Re: playing around with dicts
Jan Wielemaker <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <[email protected]> |
On 12/16/2013 03:05 AM, Richard A. O'Keefe wrote:
>
> On 14/12/2013, at 8:32 AM, Jan Wielemaker wrote:
>> I think that dicts being allowed as clause head is more a coincident
>> resulting from the fact that they currently are implemented as ordinary
>> compound terms with a reserved symbol as functor. I think that should
>> not be allowed. For one thing,
>>
>> person{name:john}
>>
>> is a different predicate than
>>
>> person{name:john, age:42}
>
> Why is it? I would expect person{name:john} to match
> any person{.....} as long as ..... included a name:john maplet.
> I would expect person{name:john, age:42} to match any
> person{.....} as long as ..... included a name:john maplet and
> an age:42 maplet. That's how record patterns work in things
> like F#.
Why it is is because how dicts are currently represented. They were not
considered predicate heads, but they are currently a special compound
term, so something happens. If you really want them in a meaningful role
in a predicate head they probably need to be compiled into something
different. Either that or raise a type error.
At this moment, unifying two dicts succeeds only if they can be made the
same. There are several other operations to do partial matching. We can
still change things here.
Cheers --- Jan