How to work with dots? When are they read as `./3` when as parts of an atom?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to work with dots? When are they read as `./3` when as parts of an atom?

Shon Feder
Hi, all,

I skimmed through the recent mailing list subjects and didn't see this
addressed elsewhere. But I am sorry if I overlooked an existing discussion!

I just fired up the newest development version, and am running *SWI-Prolog
(Multi-threaded, 64 bits, Version 7.1.8)* on OS X 9.1.

According to the note on the page for the latest development release,

> Unquoted atoms may contain internal dots. E.g., `a.b` is an atom.

But the dot seems to treated exclusively as the operator for functions on
dicts:

    ?- atom(a.b).
    ERROR: Type error: `dict' expected, found `a' (an atom)

Same thing if I try and use it as a functor:

    ?- compound(a.b(X)).
    ERROR: Type error: `dict' expected, found `a' (an atom)

Can anyone help clarify for my sake?

Many thanks!

Shon

*P.S. I'm seeing some buggy interface elements on the new (much prettier!)
SWI site. Is this a known issue, or would it be helpful for me detail what
I'm seeing?*
-------------- next part --------------
HTML attachment scrubbed and removed
_______________________________________________
SWI-Prolog mailing list
[hidden email]
https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to work with dots? When are they read as `./3` when as parts of an atom?

Shon Feder
To clarify and correct my question: I'm mainly curious what the decisive
factors are for whether the unquoted *a.b* gets read as an atom and when
it's an operator expecting the *a *to be a dict.

Also, I should note that I made the mistake of adding backquotes around *a.b
*to the quote from the SWI download page. It should have read

> Unquoted atoms may contain internal dots. E.g., a.b is an atom.

Thanks again!


On Sat, Feb 15, 2014 at 3:12 PM, Shon Feder <[hidden email]> wrote:

> Hi, all,
>
> I skimmed through the recent mailing list subjects and didn't see this
> addressed elsewhere. But I am sorry if I overlooked an existing discussion!
>
> I just fired up the newest development version, and am running *SWI-Prolog
> (Multi-threaded, 64 bits, Version 7.1.8)* on OS X 9.1.
>
> According to the note on the page for the latest development release,
>
> > Unquoted atoms may contain internal dots. E.g., `a.b` is an atom.
>
> But the dot seems to treated exclusively as the operator for functions on
> dicts:
>
>     ?- atom(a.b).
>     ERROR: Type error: `dict' expected, found `a' (an atom)
>
> Same thing if I try and use it as a functor:
>
>     ?- compound(a.b(X)).
>     ERROR: Type error: `dict' expected, found `a' (an atom)
>
> Can anyone help clarify for my sake?
>
> Many thanks!
>
> Shon
>
> *P.S. I'm seeing some buggy interface elements on the new (much prettier!)
> SWI site. Is this a known issue, or would it be helpful for me detail what
> I'm seeing?*
>
-------------- next part --------------
HTML attachment scrubbed and removed
_______________________________________________
SWI-Prolog mailing list
[hidden email]
https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to work with dots? When are they read as `./3` when as parts of an atom?

Jan Wielemaker-5
On 02/16/2014 06:20 AM, Shon Feder wrote:
> To clarify and correct my question: I'm mainly curious what the decisive
> factors are for whether the unquoted *a.b* gets read as an atom and when
> it's an operator expecting the *a *to be a dict.

I first foolishly thought it was possible to deal with that distinction
in a meaingful way, but it isn't, so, X.Y is read as .(X,Y), regardless
of the types of X and Y (well, except for floats).  The fact this worked
for floats also tricked me it could work for atoms :-(

        Cheers --- Jan

P.s. Docs are updated, but the download page still claims a.b is
        and atom.  Will fix that.

>
> Also, I should note that I made the mistake of adding backquotes around *a.b
> *to the quote from the SWI download page. It should have read
>
>> Unquoted atoms may contain internal dots. E.g., a.b is an atom.
>
> Thanks again!
>
>
> On Sat, Feb 15, 2014 at 3:12 PM, Shon Feder <[hidden email]> wrote:
>
>> Hi, all,
>>
>> I skimmed through the recent mailing list subjects and didn't see this
>> addressed elsewhere. But I am sorry if I overlooked an existing discussion!
>>
>> I just fired up the newest development version, and am running *SWI-Prolog
>> (Multi-threaded, 64 bits, Version 7.1.8)* on OS X 9.1.
>>
>> According to the note on the page for the latest development release,
>>
>>> Unquoted atoms may contain internal dots. E.g., `a.b` is an atom.
>>
>> But the dot seems to treated exclusively as the operator for functions on
>> dicts:
>>
>>      ?- atom(a.b).
>>      ERROR: Type error: `dict' expected, found `a' (an atom)
>>
>> Same thing if I try and use it as a functor:
>>
>>      ?- compound(a.b(X)).
>>      ERROR: Type error: `dict' expected, found `a' (an atom)
>>
>> Can anyone help clarify for my sake?
>>
>> Many thanks!
>>
>> Shon
>>
>> *P.S. I'm seeing some buggy interface elements on the new (much prettier!)
>> SWI site. Is this a known issue, or would it be helpful for me detail what
>> I'm seeing?*
>>
> -------------- next part --------------
> HTML attachment scrubbed and removed
> _______________________________________________
> SWI-Prolog mailing list
> [hidden email]
> https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
>
_______________________________________________
SWI-Prolog mailing list
[hidden email]
https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to work with dots? When are they read as `./3` when as parts of an atom?

Alan Baljeu


> X.Y is read as .(X,Y), regardless
> of the types of X and Y (well, except for floats). 

Well, I'm glad for this.
-------------- next part --------------
HTML attachment scrubbed and removed
_______________________________________________
SWI-Prolog mailing list
[hidden email]
https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
ems
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to work with dots? When are they read as `./3` when as parts of an atom?

ems
This post has NOT been accepted by the mailing list yet.
So is there a way to suppress the new dicts "magic" at least in the scope of a single
module?  I want a.b.c.d to be interpreted as .(.(.(a,b), c), d).  Currently, that is not
the case, because ./2 is expanded to be ./3.

I'm aware that the documentation says the following:

    Note that expansion of ./2 terms implies that such terms cannot be created
    by writing them explicitly in your source code.  Such terms can still be created
    with functor/3, =../2, compound_name_arity/3 and compound_name_arguments/3.

The point is that being able to just have a.b.c.d without any relation to dicts whatsoever
would be very useful for some DSLs.

Thanks in advance.

------
Serhii Mozghovyi.
Loading...