Re: a bug in current_functor

Jan Wielemaker <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <[email protected]>
On 10/29/2013 04:37 PM, Ulrich Neumerkel wrote:
> The manual reads:
>
> | current_functor(?Name, ?Arity)
> | Successively unifies Name with the name and Arity with the
> | arity of functors known to the system.
>
> While accurate, the locution "known to the system" does not seem to
> ring a bell to many. It means: access to system internals, don't.

Not entirely. It allows generating an upperbound, just like
current_atom/1 does. Indeed, I wouldn't really know a sensible usage for
this upperbound except for debugging purposes.

> Is there any use to it?  Except for debugging purposes, if the number
> of registered functors goes up for no reason?  But then a better place
> would be some system module.
>
> It cannot be for backwards compatibility, since in DECsystem 10
> Prolog, the second argument used to be a structure.
>
> current_functor(Name,Functor)
>     Generates  (through backtracking) all currently known functors, and
>     for each one returns its name and most general  term  as  Name  and
>     Functor  respectively.  If  Name  is given, only functors with that
>     name are generated.

I really do not recall why it got there. I assume because I was working
sort of systematically through compatibility with C-Prolog or Quintus or
whatever Prolog. I see little reason to remove it or change it either as
long as nobody comes up with some sensible usage scenario. Possibly a
comment that this is only sensible for debugging and not all systems
provide it (I think quite a few systems do not have the concept; they
simply use atom/arity pairs) and have no clue whether there are or ever
have been compounds with that pair.

	Cheers --- Jan
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.