Re: "dict"ionary typing?

Shon Feder <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <CAG+hd-gvs1xu+Q4b8oHWuSTa9anTt5yn98k+Fdaiiqbshmj3xA@mail.gmail.com>
>
> It has the same expansion as the other implementations you mention.
>

This strikes me as one of the neater aspects of getting function syntax
with expansions; for it guarantees that even the most hyper-terse,
labyrinthine tangles of functions can be automatically parsed into a very
explicit chain of statements describing the function values. Thus, a
functional expression is just a more compact representation of a
constellation of relations, and if one wants to produce a program that is
just vanilla Prolog, `listing/0` has you covered.

However, it looks to me like Jan might be disinclined towards this
approach, for reasons that are a bit beyond my ken, but which I'm sure, are
important.

On a different matter, while I think that the 'func' syntax is crisper than
what I was suggesting, the dots seem to be circulating as an enticing
candidate and I wanted to clarify a point about the .suffix notation incase
there was any mistake:

The '.of' is not an operator, but just a sub-atom. The term_expansion/2
rule just looks for functors with that suffix, and then calls the predicate
to which their attached. I don't know whether this is a good idea or a bad
one, but it seems to be a different approach from what Jan and Alan have
been discussing in the "Functional Notation", thread.




On Thu, Dec 5, 2013 at 9:13 AM, Michael Hendricks <[email protected]> wrote:

> Hi Shon,
>
> On Thu, Dec 5, 2013 at 7:48 AM, Shon Feder <[email protected]> wrote:
>
>> I believe that what you are describing, Michael, is *exactly* what Carlo
>> Capelli announced with his `lifter` package, in the "Functional Syntax"
>> thread yesterday:
>>
>
> Yes.  I posted my thoughts to an issue on https://github.com/mndrix/funca few days before I first heard of Carlo's work.  I was reassured that he
> and I had come to the same solution.  I plan to implement this for
> library(func) tomorrow.  Probably using ~ instead of º since the latter is
> not readily available on my keyboard :-)
>
>
>> I have used the module (https://github.com/CapelliC/prolog-snippets) and
>> I find it quite interesting. Carlo's approach is interesting for exactly
>> the reasons you note.
>>
>
> If you haven't yet, you might also look at the "func" pack at
> http://www.swi-prolog.org/pack/list?p=func  Many of your ideas about
> predicates as functions are implemented there.  You might also like the
> "function_expansion" pack at
> http://www.swi-prolog.org/pack/list?p=function_expansion which makes it
> easy to create additional function-like behavior.
>
>
>> With `lifter`, the clause
>>
>>     longer(A,B) :-
>>         length(A,º) > length(B,º).
>>
>
> With func, this is written:
>
>     longer(A,B) :-
>         length $ A > length $ B
>
> It has the same expansion as the other implementations you mention.  $/2
> works with any predicate, using the final argument as the output.  It
> behaves similarly to ".of" which you describe.
>
> func also lets you compose predicates as if they were functions.  It's
> really just an extension of your idea that we can use the final argument of
> a predicate as its output.  For example, we might craft our own version of
> atom_length/2 with
>
>     % apply atom_codes/2 and then length/2
>     AtomLength = length of atom_codes
>
> then we might call(AtomLength, hello, N) and see N=5.  Or using sugar
> writeln(AtomLength $ hello) to display "5".
>
> In any case, I have really enjoyed reading these discussions recently ...
>>
>
> Me too.  Thank you for contributing your thoughts to the discussion.
>
> --
> 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.