| Deutsch English Français Italiano |
|
<vh5o8p$6c48$1@solani.org> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!news.roellig-ltd.de!open-news-network.org!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: Re: How Prolog became an education nightmare (Was: 50 Years of Prolog
Nonsense)
Date: Thu, 14 Nov 2024 21:58:02 +0100
Message-ID: <vh5o8p$6c48$1@solani.org>
References: <db903ba2-8ccd-418e-bd18-a9eb381cd222n@googlegroups.com>
<e5616850-37a8-46fd-b2a8-e3ca252b8a5an@googlegroups.com>
<vgvsb7$3e31$1@solani.org> <vgvseq$3e31$2@solani.org>
<vh3tel$57pk$1@solani.org> <vh5m4u$2o1jf$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 14 Nov 2024 20:58:01 -0000 (UTC)
Injection-Info: solani.org;
logging-data="209032"; mail-complaints-to="abuse@news.solani.org"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Firefox/91.0 SeaMonkey/2.53.19
Cancel-Lock: sha1:KnfA1hEtTJnRuUUBYMFQei9YS1U=
In-Reply-To: <vh5m4u$2o1jf$1@dont-email.me>
X-User-ID: eJwNysEBwCAIA8CVxJAo4wjK/iO09z5CplouytnsakCZA+fG83oePDtRM9n/Ol4YWmvusqBFGCyP3nVCRR8fW3AVAA==
Bytes: 3030
Lines: 70
Yes, maybe, it depends. You would
need to fill in some logic for the
block functionality, like opening
and closing a table with variable
names. And try it as such with a larger
variety of example. Also compare whether
it works for both SWI-Prolog and SICStus
Prolog. What one can already see for sure,
the compile is not extremly safe anymore.
It would also accept non well formed
input. Like you can call it with unbalanced
begin end now, and the compile/1 clause
pattern matching will not fail, and it
will start producing some code:
?- compile((begin x=1 end end)).
But maybe this is a minor problem. Another
challenge is for example the Pascal if-then-else.
Basically a mixfix with 3 holes.
if _ then _ else _
https://www.tutorialspoint.com/pascal/pascal_if_then_else_statement.htm
Just like in the begin end case, where
we can provide non-well formed input
like (begin x=1 end end). Ordinary
Prolog operators will again not provide
the safety and versatility for writing rules.
Julio Di Egidio schrieb:
> This seems to do the trick:
>
> ```
> % SWI-Prolog 9.2.7
>
> :- op(1100, fy, begin).
> :- op(1100, yf, end).
>
> compile((begin XEnd)) --> compile(XEnd).
> compile((X end)) --> compile(X).
> compile((X;Y)) --> compile(X), compile(Y).
> compile((V=E)) --> [load(E),store(V)].
>
> compile_t(X, L) :-
> X = (
> begin
> x = 1;
> begin
> y = 2
> end
> end
> ),
> compile(X, L, []).
> ```
>
> ```
> ?- compile_t(X, L).
> X = (begin x=1;begin y=2 end end),
> L = [load(1),store(x),load(2),store(y)].
> ```
>
> -Julio
>