AppliedLogicSystems / ALSProlog

ALS Prolog Compiler & Development Environment
https://alsprolog.com
MIT License
16 stars 9 forks source link

length/2 loops #210

Open UWN opened 9 months ago

UWN commented 9 months ago

Not sure this is a real error or just a compilation problem. See length#3. Also git describe and the banner show different versions.


ulrich@gupu:/opt/gupu/ALSProlog$ git pull
Already up to date.
ulrich@gupu:/opt/gupu/ALSProlog$ git describe
v3.1.24-1517-g1f9f4663
ulrich@gupu:/opt/gupu/ALSProlog$ unix/linux/als-prolog/alspro 
ALS Prolog (Threaded) Version 3.5.0-287-g81d11d5a [linux]
   Copyright (c) 1987-2024 Applied Logic Systems, Inc.

Setting up library indicies...may take a moment...Done.

gc not 64-bit yet
?- length([_|L],0).
gc not 64-bit yet
^C    Break Handler
    ------------------------
    a - Abort Computation *
    b - Break shell
    c - Continue
    d - Debug
    e - Exit Prolog
    f - Fail
    p - Return to Previous Break Level
    s - Show goal broken at
    t - Stack trace
    ? - This message
Break(1) >t
(1) builtins:stack_trace(1,break_handler)
(2) builtins:
    break_handler(stack_trace,builtins,_A is 3154173+1,
        als_shl_mgr(als_shl_mgr,builtins,1...))
(3) builtins:catch0(builtins,?,?)
(4) builtins:breakhandler(builtins,_A is 3154173+1)
(4) builtins:_A is 3154173+1
(5) builtins:length(?,3154173,0)
--Bottom of Stack--
    Break Handler
    ------------------------
    a - Abort Computation *
    b - Break shell
    c - Continue
    d - Debug
    e - Exit Prolog
    f - Fail
    p - Return to Previous Break Level
    s - Show goal broken at
    t - Stack trace
    ? - This message
Break(1) >c
gc not 64-bit yet
...
gc not 64-bit yet
Segmentation fault (core dumped)
chuckhoupt commented 9 months ago

Thanks for the report. I'll answer the git-describe question first while I research the length/2 issue:

The reason git describe shows an ancient version number is because by default git describe only displays annotated tags. If you use git describe --tags it will show the lightweight tag used for v3.5.0. Ideally we would have used annotated tags for all release versions, but Github has a bug/mis-feature that it only tags releases made in the UI with lightweight tags.

UWN commented 7 months ago

... while I research the length/2 issue

Not sure I was clear about it, but there is a draft https://www.complang.tuwien.ac.at/ulrich/iso-prolog/prologue#length for length/2 which is followed quite closely by many implementations http://www.complang.tuwien.ac.at/ulrich/iso-prolog/length

Note that there is no need to be perfect as to the detection of all kinds of loops although the more modern systems all detect such cases rapidly. So looping for a case like http://www.complang.tuwien.ac.at/ulrich/iso-prolog/length#22 is fine. More sophisticated implementations produce a resource_error rapidly which is preferable form a resource consumption viewpoint.