Home > Archive > Prolog > April 2007 > Dali : A standard data structure library for Prolog
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Dali : A standard data structure library for Prolog
|
|
| koen plasmans 2007-04-08, 7:03 pm |
| Hi everybody,
I'm a thesis-student at the university of Leuven (Belgium).
For my thesis, I have to make a standard data structure library for
Prolog.
It's standard because it only uses the ISO prolog subset of the
language.
I've already finished a part of this library and called it Dali (DAta
LIbrary).
The library can be downloaded from : http://kookpot.studentenweb.org/thesis/dali.zip
It offers functionality for 7 data structures and in the directory
docs, you can find the documents of those data structures.
I wanted to ask for your opinion on my library. If you've got remarks,
questions on the library, email them to me. I also want to ask to
point me to already existing data structure modules in prolog, so that
I can compare my implementations.
Thank you in advance.
Koen Plasmans,
K.U.Leuven,
Belgium.
| |
| bart demoen 2007-04-09, 7:03 pm |
| On Sun, 08 Apr 2007 07:44:55 -0700, koen plasmans wrote:
> I wanted to ask for your opinion on my library. If you've got remarks,
> questions on the library, email them to me.
Bad netiquette: you ask a question on a newsgroup, expect public answers,
not private ones.
Anyway, I went through the first 50 lines of boolean.pl and here are some
questions:
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 ?
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"
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 !
Maybe more remarks/questions after I see reasonable answers to the above :-)
Cheers
Bart Demoen
| |
|
|
| koen plasmans 2007-04-18, 8:03 am |
| > 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 :-).
| |
|
|
|
|
|