Deutsch   English   Français   Italiano  
<vsj1k3$m6op$1@solani.org>

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

Path: news.eternal-september.org!eternal-september.org!feeder3.eternal-september.org!news.mixmin.net!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: Streamable DOM and obsolete put_code/[1,2]
Date: Wed, 2 Apr 2025 11:56:20 +0200
Message-ID: <vsj1k3$m6op$1@solani.org>
References: <vsj1an$m6gi$1@solani.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 2 Apr 2025 09:56:19 -0000 (UTC)
Injection-Info: solani.org;
	logging-data="727833"; 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:fqIzBE51rN7D+h9QhxESloAwCd4=
In-Reply-To: <vsj1an$m6gi$1@solani.org>
X-User-ID: eJwFwYEBwDAEBMCVIuUxTvD2H6F39kHQrjCore0lWsZvvaiOoOfhqvspt6Q2gr1hPpWISeZTeYIrOpS7/AFjIxXm

Hi,

Streamable DOM in the form of a "HTML writer",
can be a real miracle. SWI, Ciao, etc.. none
of the Prolog systems have a "HTML writer",

it seems the prospect of a HTMLParser inside such
"HTML writer", and that it is a state machine
confuses the world view of many people. But

the idea was already pursued by Tau Prolog.
Just take an element:

 > <div id="writeme"></div>

And then literally you only have to open it:

 > :- use_module(library(dom)).
 >
 >output :-
 >    get_by_id(writeme, WriteMe),
 >    open(WriteMe, write, Stream),
 >    write(Stream, hello),
 >    write(Stream, world).

But it didn't have much adoption, rather cause more
problems than solved any:

 > How getting all the sandbox output into html?
 > joseph-vidal-rosset opened on Aug 2, 2022
 > https://github.com/tau-prolog/tau-prolog/issues/326

I do not blame the Philosopher trying to be a
Prolog programmer. It had not much utility since
write/1 now accepted and inserted HTML.

Bye

Mild Shock schrieb:
> Hi,
> 
> The development of Novacore takes interesting turns.
> Originally more accidentially, because I observed it
> can serve a few interesting use cases, like atomic
> 
> logging with some unspoken or spoken gurantees,
> I introduced put_atom/[1,2] in Novacore streams:
> 
>  > put_atom(S, A):
>  > The built-in succeeds. As a side effect, it adds
>  > the atom to the stream S.
> 
> Now because I am revising my streamable DOMs, the
> "HTML writer" part, I even went so far as to
> bootstrap put_code/[1,2] from it:
> 
>  > put_code(Stream, Code) :-
>  >    char_code(Atom, Code),
>  >    put_atom(Stream, Atom).
> 
> One can eliminate each put_code/[1,2] call such
> as put_code(S, 0'\n) by a put_atom/[1,2] call
> such as put_atom(S, '\n'). The performance is the
> 
> same, in my case can be slighly better since under
> the hood put_code and put_atom called the same
> stream meachnism.
> 
> But the main reason I eliminate put_code was
> to have a single point. Because the Prolog
> write_term/1 is 100% written in Prolog, in the
> 
> end it only only uses put_atom.
> 
> Bye