Re: defining operators with a result
- From: Jan Wielemaker <jan@xxxxxxxxxxxxxxxxxxx>
- Date: 14 Nov 2006 08:08:38 GMT
On 2006-11-13, Richard Szopa <ryszard.szopa@xxxxxxxxx> wrote:
First of all, thank you all for your answers.
I think that the solution proposed by Glenn Lieding doesn't really
solve my problem. Having to adapt every predicate to deal with the mton
structure won't make my code more compact or more readable. Also, I
would like to be able to use my notation in built-in predicates, like
for example reverse and so on.
On the other hand, GRIPS goes much too far for me--I realize that
Prolog uses relational notation and I'm quite happy with it. Also, I
find remaining understandable for the rest of Prolog programmers quite
important. ;-)
The idea of trying to add this sugar to Prolog came to me when I found
that I use [m..n] quite often in my pseudo-Prolog code, but when I
translate it into Prolog, it gets somehow more obscure.
Anyway, an additional question: how would one define in Prolog |, the
cons operator, if it wasn't built in the language and f one wanted it
work exactly as | works now in [Head|Tail]? Or, if one wanted to be
able to use the '@' sign in one's Prolog programs instead of '|'? Is
it possible?
You can't. The only thing you can do is define operators that allow you
to write terms as "f A", "A f B" or "A f". List syntax is built-in
syntactic sugar for .(Head, Tail). Same for {...} is {}(...). I'm mostly
happy with this. Even operators are a serious source of portability and
integration problems. Use them with care, do not overrule built-in
operators and -if your implementation allows for it-, keep them local
in modules.
Enjoy --- Jan
.
- References:
- defining operators with a result
- From: Richard Szopa
- Re: defining operators with a result
- From: Nameless
- Re: defining operators with a result
- From: Richard Szopa
- Re: defining operators with a result
- From: Jan Wielemaker
- Re: defining operators with a result
- From: Richard Szopa
- defining operators with a result
- Prev by Date: Re: defining operators with a result
- Next by Date: Re: defining operators with a result
- Previous by thread: Re: defining operators with a result
- Next by thread: Re: defining operators with a result
- Index(es):
Relevant Pages
|
|