Re: [eclipse-clp-users] [SWI-Prolog/swipl-devel] user-data-type-attvars (#189)

From: Kish Shen <kish.shen_at_gmail.com>
Date: Fri, 6 Jan 2017 21:39:58 +0000
Hi Douglas,

I assume you are posting this question about ECLiPSe, rather than
SWI-Prolog, as your title seem to suggest.

To unify V1=V2

...

>   Could V1 and V2 still be different variables?


No. Once you unify 2 terms, they become the same, i.e. V1 and V2 represent
the same variable after unification, and there is only one attribute for
the variable. This is a fundamental property of unification in Prolog.

>  get a wakeup to decide the my_string_words were a okay to unify


User defined unification handlers (one per attribute)  is invoked when a
attributed variables are unifiied. The handler should define the
unification behaviour for the attribute, for example, how to merge the two
original attributes into the single attribute after unification.

There is a chapter on attributed variables in the user manual:

http://eclipseclp.org/doc/userman/umsroot093.html

which I strongly recommend you to consult if you haven't done so.

On a more general point:

>I would like believe that I can use attvars/metaterms to proxy for complex
datatypes.

This is not what attributed variables are designed for. I think you should
use normal Prolog (variables and data structures) to implement your string
type, rather than trying to push them into an attribute.

Cheers,

Kish



>
>
On Mon, Jan 2, 2017 at 9:05 AM, Douglas Miles <logicmoo_at_gmail.com> wrote:

> I' just start the email over sorry so sorry
>
> (i had to clear up between my_string_words and pretend_value .. and they
> were meant to be the same attribute)
>
>
>
> ​Hi
>
> I would like believe that I can use attvars/metaterms to proxy for complex
> datatypes.
>
> Lets pretend I created a fake string datatype that holds sentences using
> entire words like [hello,world]  .. I'll print this as "hello world"
> Let add that this datatype can also hold unbound word element to  like
> [hello,_].
>
> I'll store these physically in an attribute called  my_string_words
>
> so far so good?
>
>
> V1 =  my_string_words([hello,beautiful,world])   + had an attribute  foo
> (inst1)
> V2 = another my_string_words([hello,_])   + had an attribute  foo(inst2))
>
>
> It would possible (if i so wanted)
>
> To unify V1=V2
>
> I get a wakeup to decide the my_string_words were a okay to unify
>
> And have the outcome be be that if i checked the values.. I will been
> allowed to modify  my
> my_string_words of V2 to now be [hello,world]  ?   I am guessing the
> answer is still yes
>
> Here is the question:
>
>    Could V1 and V2 still be different variables?
>   could possibly still find different 'foo' attributes  V1 and V2
> respectively?​
>
>
>
> Thank you in advance,
>  Douglas
>
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> _______________________________________________
> ECLiPSe-CLP-Users mailing list
> ECLiPSe-CLP-Users_at_lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/eclipse-clp-users
>
>
Received on Fri Jan 06 2017 - 21:40:10 CET

This archive was generated by hypermail 2.2.0 : Sat Jan 07 2017 - 00:13:11 CET