Re: Dali : A standard data structure library for Prolog
- From: koen plasmans <koentjeplasmans@xxxxxxxxxxx>
- Date: 18 Apr 2007 04:00:31 -0700
Bad netiquette: you ask a question on a newsgroup, expect public answers,
not private ones.
I guess it's obvious I don't write alot in newsgroups :-). I just
didn't want to bother anyone but I guess that's the risk of being in a
newsgroup.
1) isn't it an overkill to have every exported predicate start with
boolean in you boolean.pl ? Isn't the module system good enough to
make typing the redundant prefix boolean_ totally redundant ?
Unfortunately, the prefix is necessary. If a person wanted to load two
of my graph-modules without the prefixes, the second module wouldn't
be loaded because of name clashes. I don't see how I can resolve those
name clashes in the module system I use. Logtalk solves the name
clashes but we need to type the modulename as prefix again.
2) boolean_boolean/1 has as comment:
Checks if a given atom is a boolean or not
but also part of the comment is
"boolean_boolean(-Boolean:boolean) is semidet."
What does "checking" mean with mode - ?
Or perhaps I should ask: what is your notion of mode - or semidet ?
Because my notions would make the comment into
"boolean_boolean(-Boolean:boolean) is multidet"
That's indeed a mistake. It should be multi or multidet and the
comments I use are a little bit strange. I'm just not used to write
comments in a logic programming language. I'm working on it right now.
By the way, is there a tool to test or generate determinism of a
predicate? That would make it easier to remove mistakes like the
above.
Let's now look at the first clause of your definition of boolean_and/3:
boolean_and(false, _, false).
Why is it not
boolean_and(false,X,false) :- boolean_boolean(X).
?
I am asking because your second clause of boolean_and/3 suggests that you
want to deal with ill-typed input, but the first one doesn't. Why ?
And about the second clause:
boolean_and(true, Boolean, Boolean):-
boolean_boolean(Boolean).
why did you choose to fail on non-boolean input (second arg) to this pred,
instead of throwing an error: throw [or raise_exception, I can't
remember which] is ISO after all !
The code of boolean_and/3 should be :
boolean_and(true,Boolean,Boolean).
I don't offer the detection of input-errors. It would slow down every
predicate. In worst case it would slow down a predicate by a constant.
Efficiency is my goal therefore I try to keep my predicates as "light"
as possible.
I do offer the option of testing input (boolean_boolean/1) but the
programmer has to add the code himself.
Maybe more remarks/questions after I see reasonable answers to the above :-)I truly appreciate the remarks and question.
My project is now also available at : http://sourceforge.net/projects/dali-prolog/
Cheers,
Koen Plasmans.
P.S.: Sorry, for replying so late. I was busy writing my thesis :-).
.
- References:
- Dali : A standard data structure library for Prolog
- From: koen plasmans
- Re: Dali : A standard data structure library for Prolog
- From: bart demoen
- Dali : A standard data structure library for Prolog
- Prev by Date: Re: importing a library
- Next by Date: i am a prolog beginner pls help me in getting this
- Previous by thread: Re: Dali : A standard data structure library for Prolog
- Next by thread: SWI-Prolog best choice for GPL-licensed Windows-compatible processor?
- Index(es):
Relevant Pages
|