Re: Ann: SWI-Prolog 6.5.3

Michael Hendricks <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <CAFHuXua0fFTkNp42Lph_Jg18KM1p9NOVafKxge-k5=+us0+3Fw@mail.gmail.com>
On Thu, Nov 21, 2013 at 4:47 AM, Jan Wielemaker <[email protected]> wrote:

> On 11/21/2013 05:47 AM, Michael Hendricks wrote:
>
>>
>>     In the same way, in the NU Prolog approach, a byte-per-element string
>>     *IS* a code list, just stored differently.
>>
>>
>> I think this is an important point worth extra attention.  In one sense,
>> [H|T] is just a comfortable interface for sequences of data.  A linked
>> list is the traditional sequence, but string-stored-as-byte-array is a
>> sequence too.  A sequence might be the key-value pairs in a map or the
>> bytes in a stream, etc.  Clojure sequences take the idea to its
>> conclusion by abstracting the cons interface so that many data
>> structures can implement it.
>>
>> I'd love to see this idea in more Prologs.
>>
>
> I don't think it is that easy.


I agree that it's not easy.  Prolog is a fantastic interface to my CPU's
instruction set, but it's taken a lot of hard work to get there :-)


>  [H|T] is syntactic sugar for a data structure, not for an operation.


We can also imagine it as sugar for a relation. foo([H|T]) might desugar to

    sequence(H,T,Whole),
    foo(Whole).

With coroutines and appropriate definitions for sequence/3 you can get both
reading and writing.  I've experimented with this arrangement on a couple
data structures.  I think it can extend to others, but I may be wrong.  If
it pans out, I'll release it as a pack.

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