Re: "dict"ionary typing?

Kilian Evang <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <[email protected]>
On 27-11-13 19:53, Alan Baljeu wrote:
> 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'm also concerned about this. It feels inconsistent.

Couldn't is/2 be overloaded for the purpose of functional assignment, so
that the above would become

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

I realize the functional notation could not be used directly in goal
arguments then. But so what? That's Prolog. IMHO a consistent syntax is
well worth the slight added verbosity.

Kilian
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.