Re: playing around with dicts

Jan Wielemaker <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <[email protected]>
On 12/17/2013 05:33 AM, Richard A. O'Keefe wrote:
>
> On 16/12/2013, at 9:41 PM, Jan Wielemaker wrote:
>>
>> Why it is is because how dicts are currently represented.
>
> I wasn't asking "what is it about the current implementation
> that makes this not work" but "what is it about the abstract
> semantics that makes it inappropriate".  LIFE psi-terms
> _could_ be clause heads.

Yes. Reading through the LIFE tutorial for which a link was posted here
though, I came to the conclusion that LIFE is, at least at the moment, a
bridge too far from Prolog. I have the impression that introducing dicts
does not make it more difficult to introduce more LIFE concepts later.
Unless I'm really wrong here, I'd like ignore LIFE for now.  Mostly
due to lack of resources.

>> 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.
>
> In the "frames" design I did for Erlang, I initially made
> frame construction expressions and frame patterns symmetric.
> But that turned out to miss the whole point of having frame
> patterns: typically you only _want_ to match a few fields.
>
> We were discussing
>> person{name:john} to match
>> any person{.....} as long as ..... included a name:john maplet.
>
> and that is *precisely* a case where the pattern and the argument
> can be made the same.  I've forgotten the LIFE syntax, so I'll
> make it up, but
>
>	person(name=>john, height=>197) :-
>	    ...
> would certainly match
>
>	?- person(age=>42, name=>john)
>
> because both terms unify to yield
>
>	person(age=>42, height=>197, name=>john).

This is an interesting thought and this might happen later.  At
this moment, dicts cannot be extended without changing identity,
which makes this impossible.  It is not hard to see ways to make
this possible in the future though.  I will add a remark to the
docs about unification.

	Cheers --- Jan
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.