Deutsch   English   Français   Italiano  
<100uget$8qmr$1@solani.org>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!weretis.net!feeder8.news.weretis.net!reader5.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From: Mild Shock <janburse@fastmail.fm>
Newsgroups: comp.lang.prolog
Subject: prolog_file_name/2 was a big mistake [Novacore]
Date: Sun, 25 May 2025 09:22:08 +0200
Message-ID: <100uget$8qmr$1@solani.org>
References: <vrkadh$7arh$1@solani.org> <vrkanf$7b21$1@solani.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 25 May 2025 07:22:05 -0000 (UTC)
Injection-Info: solani.org;
	logging-data="289499"; mail-complaints-to="abuse@news.solani.org"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101
 Firefox/128.0 SeaMonkey/2.53.20
Cancel-Lock: sha1:BBtdINVPAT18Pm7d+xmQGjhPawI=
X-User-ID: eJwNwokRwDAIA7CVnIChjFO+/UdodaLYsXI1mnK5T6x4pkWnTypiKO2svuAUE845lc1pSOAeZcR6Ayb/9wNeCBU1
In-Reply-To: <vrkanf$7b21$1@solani.org>
Bytes: 4106
Lines: 113

Hi,

The GNU Prolog specification of prolog_file_name/2
was a big mistake. It reads as follows:

prolog_file_name(File1, File2) unifies File2 with the
Prolog file name associated with File1. More precisely
File2 is computed as follows:

- if File1 has a suffix or if it is user then File2
   is unified with File1.
- else if the file whose name is File1 + ’.pl’ exists
   then File2 is    unified with this name.
- else if the file whose name is File1 + ’.pro’ exists
   then File2 is unified with this name.
- else if the file whose name is File1 + ’.prolog’ exists
   then File2 is unified with this name.
- else File2 is unified with the name File1 + ’.pl’.

This predicate uses absolute_file_name/2 to check the existence of a 
file (section 8.26.1).

http://www.gprolog.org/manual/html_node/gprolog050.html#hevea_default836

It was adopted by SWI-Prolog and made parameterizable through
absolute_file_name/3:

https://www.swi-prolog.org/pldoc/doc_for?object=absolute_file_name/3

The big mistake is the existence check. In a web context
it requires a server rountrip or something. And since there are
3 existence checks, its 3 server rountrips possibly HEAD requests.

Formerly Jekejeke Prolog suffered from this problem. Now
with Dogelog Player and as part of Novacore we wanted to
do something else. What is the solution?

Bye

Mild Shock schrieb:
> Hi,
> 
> Somehow I have the feeling it doesn't make
> sense to only recognize floating point numbers
> as number literals that have a period in it.
> 
> Most programming languages I have encountered
> also recognize floating point numbers when
> they have an exponent e or E in it:
> 
> - Python:
>  >>> 1e19
> 1e+19
> 
> - JavaScript:
>  > 1e19
> 10000000000000000000
> 
> JavaScript is a little special. Since it has a
> integer subset inside there floating point numbers.
> Now I find that SWI-Prolog also allows 1e19:
> 
> /* SWI-Prolog 9.3.20 */
> ?- X = 1e19.
> X = 1.0e+19.
> 
> I think this is a good idea. Since there is no
> confusion. Most Prolog systems I checked never
> alias an operator e with a number:
> 
> /* SWI-Prolog 9.3.20 */
> ?- op(500,yfx,e).
> true.
> 
> ?- X = 1 e 2.
> X = 1 e 2.
> 
> Bye
> 
> Mild Shock schrieb:
>> Interestingly a flag strict_iso could solve a few
>> vexing problems. For example the ISO core standard
>> did only mention floor/1 with signature F → I.
>>
>> So in GNU Prolog I can do:
>>
>> /* GNU Prolog 1.5.0 */
>>
>> ?- current_prolog_flag(strict_iso, X).
>> X = on
>> yes
>>
>> ?- X is floor(1).
>> uncaught exception: error(type_error(float,1),(is)/2)
>>
>> ?- set_prolog_flag(strict_iso, off).
>> yes
>>
>> ?- X is floor(1).
>> X = 1
>> yes
>>
>> A few Prolog systems don’t share the above behavior,
>> like SWI-Prolog for example doesn’t throw the type error.
>> Also SWI-Prolog has nowhere a flag strict_iso.
>>
>> Currently I have changed my Prolog system to tell me:
>>
>> /* Dogelog Player 1.3.1 */
>>
>> ?- current_prolog_flag(strict_iso, X).
>> X = off.
>