Re: Predicate ordering when using current_predicate/1

emacstheviking <[email protected]>
Newsgroups gmane.comp.gnu.prolog.general
Message-ID <CAEiEuU+aFXY5j65ENqPH711ai4wAF+4nhY6Xu3NB4oeJ2seGaQ@mail.gmail.com>
I *used* to sort them but that destroys the order I want to have them
execute in. I wanted them to execute in the order they are declared in the
file... the only other alternative I thought about was manually parsing the
file and finding all lines starting with "test_" and doing it that way...
maybe I will!

I will find a way that is simple.

No worries.



On 21 November 2013 16:08, Paulo Moura <[email protected]> wrote:

>
> On 21/11/2013, at 16:04, emacstheviking <[email protected]> wrote:
>
> > I really don't want to go down that road but I guess if there is no
> choice I will have to... originally I had a predicate that explicitly
> returned the tests... I think I will do both... I will have a predicate
> that if it exists, can return a bunch of tests and they will be executed in
> order.
>
> Can't you simply sort the list resulting from the findall/3 call or use
> setof/3?
>
> Cheers,
>
> Paulo
>
> > OK, I can live with that,
> > thanks again Paulo!
> > :)
> >
> >
> >
> > On 21 November 2013 15:56, Paulo Moura <[email protected]> wrote:
> >
> > On 21/11/2013, at 15:48, emacstheviking <[email protected]> wrote:
> >
> > > Hi,
> > >
> > > There is no mention of the actual order of returned predicates,
> >
> > For a good reason. That's not something that you should rely upon.
> >
> > > recently I created a testing framework and it has this line of code
> thanks to Daniel,
> > >
> > > findall(Name,(current_predicate(Name/0), atom_concat('test_', _,
> Name)),AllTests)
> > >
> > > I am writing tests now that rely upon them being executed in the order
> that they are defined in the source file i.e. the temporal order in which
> they were added to the database I presume.
> > >
> > > However, they do not seem to come out in the expected order unless I
> have done something wrong but the above line of code is what dictates the
> order of execution.
> >
> > An alternative could be to use an identifier per test that you can
> compare and sort. An example from the Logtalk's "ack" example unit tests:
> >
> > test(ack_1) :-
> >         ...
> > test(ack_2) :-
> >         ...
> > test(ack_3) :-
> >         ...
> >
> > Cheers,
> >
> > Paulo
>
> -----------------------------------------------------------------
> Paulo Moura
> Logtalk developer
>
> Email: <mailto:[email protected]>
> Web:   <http://logtalk.org/>
> -----------------------------------------------------------------
>
>
>
>
>
> _______________________________________________
> Users-prolog mailing list
> [email protected]
> https://lists.gnu.org/mailman/listinfo/users-prolog
>

_______________________________________________
Users-prolog mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/users-prolog
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.