Re: Some thoughts on dicts in SWIPL 7

Carlo Capelli <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <CABty9wxGe4n3wENtk7mn+FqwCMXbsvehfM6bu7MOqFGLDi4BVA@mail.gmail.com>
2014-02-18 11:48 GMT+01:00 Jan Wielemaker <[email protected]>:

> On 02/18/2014 11:27 AM, Carlo Capelli wrote:
> >
> > I forgot: a pattern that could be handy could be a member_dict/2, to
> > avoid this kind of code
> >
> > (member(F, T.foreignKeys), F >:< _{pkCol:PkCol, fkTable:FkTable,
> > fkCol:FkCol})
>
> I think I'm missing something:
>
> 16 ?- A is _{a:1, b:2}.Key.
> A = 1,
> Key = a ;
> A = 2,
> Key = b.
>
> What am I missing?
>

What I meant: porting older code, that was like

table(T, ..., ForeignKeys),
member(foreignKey(PkCol,FkTable,FkCol), ForeignKeys)

I initially wrote

member(_{pkCol:PkCol, fkTable:FkTable,fkCol:FkCol}, T.foreignKeys),

and that worked. Then I realized that if I add a field to foreignKeys, it
will fail...
Still learning, of course...

>
>         Cheers --- Jan
>
-------------- next part --------------
HTML attachment scrubbed and removed
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.