Re: "dict"ionary typing?

Alan Baljeu <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <[email protected]>
I'm eager for dictionaries to be a great feature in SWI,

including highly usable syntax.  Thus I'm pressing for 
improvements before things get locked in.  Is anyone else 
concerned about the proposed syntax?

I suppose things like this are the primary motive for 
the new syntax.  

M.polar_radius() := D :-
           D is sqrt(M.x*M.x + M.y*M.y).

?- P = point{x:3, y:4}, X = P.x, D = P.polar_radius().



However, I'm struggling to accept this.  I feel it confuses 
the standard meaning of =/2 as "unify terms".  Here the right 
side feels like it ought to be a term but I gather it isn't.
(And if it isn't a term, it can't be meta-programmed?)
Newcomers will think functional notation and be baffled when 
P = 2+3 doesn't work.

I might prefer P.polar_radius(D), and if that's sugar 
for polar_radius(P,D) this  is okay because I can still use 
X = P.polar_radius, call(X,D).  As is, even if you have some 
magic that makes all uses behave correctly, I will find it 
confusing.

I'm also skeptical about the usefulness of functional chaining 
like P.foo().bar() given the performance characteristics. How 
often should a function on a dictionary return another 
dictionary?


---

Different question: Can this work?



?- X = P.x, P = point{x:3, y:4}.


>> I guess there are two main uses for a dict:

>> a) as a struct where there are fixed elements of varying types.
>> b) as a map where there are variable elements of fixed types.

>Not sure I get that.

I mean this: 
a)window{top: 0,bottom: 100,left:2,right:12, background: red, controls: List}


b)dictionary{cat, 'small animal with whiskers', dog, 'domestic animal that barks'}
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.