Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.prolog > #15886
| From | Mild Shock <janburse@fastmail.fm> |
|---|---|
| Newsgroups | comp.lang.prolog |
| Subject | Some variable scoping tricks (Was: The missing genius of Web Prolog) |
| Date | 2026-08-24 17:07 +0200 |
| Message-ID | <116hmnh$11d72$3@solani.org> (permalink) |
| References | <116hmgl$11d72$1@solani.org> <116hml2$11d72$2@solani.org> |
Hi,
P.S.: A variant 1 workaround would be to allow
quantifiers in a query, like for example (^)/2 as
already found in setof/3. But then one runs into
the annoying opt-out accumulation:
?- ..., PID ! X1^X2^X3^person(ID, X1, X2, AGE, X3), ...
P.P.S.: Although switching from opt-out to opt-in would
be a solution in this matter, sending programs could be also
a variant 2 solution, for example an RPC where I
can send a temporary program and a query would also
do the job, see this rpc/3 example:
?- ..., rpc(PID, person_age(PID, AGE),
{person_age(PID, AGE) :- person(ID, _, _, AGE, _)}), ... .
It has mindboggling variable scoping, {}/1 doing
automatic universal quantification, just like input
clauses are read in a Prolog text according to ISO
core standard semantics, but practically one runs
into problems whether the provided program should
more have some embedded implication semantics and have
not all variables automatically universally quantified,
so as to capture terms, and here transmit to the PID,
from the calling context.
Bye
Mild Shock schrieb:
> Hi,
>
> I have some doubt that Web Prolog captures the
> wisdom of 70 years of distributed database engineering.
> Or maybe the Trinity Web Prolog concept paper does
>
> not talk about it. But the general structure of SQL queries is:
>
> SELECT projection
> FROM source
> WHERE condition
>
> Now I have a problem with Web Prolog when I would like
> to do very simple remote things like for example, which can be
> highly optimized in traditional WAM based Prolog systems,
>
> the way anonymous variables can be represented. You see
> this in the GNU Prolog FFI, in the C declarations from <gprolog.h>,
> where an argument can be marked as wanted on return or not:
>
> ?- ..., PID ! person(ID, _, _, AGE, _), ...
>
> What a Web Prolog might see at runtime is only:
>
> ?- ..., 9167 ! person(3524, _1, _2, _3, _4), ...
> The pengine, although it can do paging or whatever, will
> then happily send back over the wire a very large JSON
> packet which will have the answer in its data field:
>
> {
> ...
> data:{"_1":..., "_2":...", "_3":..., "_4":...}
> }
>
> But from the intention of the original query we would like only:
>
> {
> ...
> data:{"_3":...}
> }
>
> So while Web Prolog gives me some traits of a ResultSet
> from SQL, like paging. I think a mechanism for select projection
> is missing, while SQL happily does that as well in its ResultSet.
>
> Its quite a tricky problem, since it shatters the whole idea of
> a simple (!)/2 binary operator for Prolog based RPC. Maybe it
> can be solved on the compiler side with an analysis that
>
> provides the GNU Prolog FFI flags. But then the Prolog based
> RPC becomes more than a new built-in with a beautifully
> looking (!)/2 binary operator, it would also require some
>
> intervention in compiler technique from the Prolog system.
>
> Bye
>
> Mild Shock schrieb:
>> Hi,
>>
>> We really find a lost Genius in GNU Prolog FFI.
>> It has this wonderful thing. The field "unify"
>> controls whether the actual argument must
>>
>> be unified at the exit of the C function.
>>
>> 10.3.6 Input/output arguments
>> typedef struct
>> {
>> PlBool is_var;
>> PlBool unify;
>> union
>> {
>> PlLong l;
>> char *s;
>> double d;
>> }value;
>> } PlFIOArg;
>>
>> Judging from just looking at it, one can basically
>> communicate "don't care" arguments, usuall expressed
>> as "_" i.e. annonymous variables, or some variants
>>
>> of Prolog systems also allow "_Name", but effectively
>> variables that only occure at one call site location.
>> But why is it lost. It is slowly subject to bit rot.
>>
>> > www.gprolog.org verwendet ein ungültiges Sicherheitszertifikat.
>> >
>> > Das Zertifikat gilt nur für folgende Namen: trantor.univ-paris1.fr,
>> > *.univ-paris1.fr, univ-paris1.fr, *.pantheonsorbonne.fr,
>> > pantheonsorbonne.fr
>> >
>> > Fehlercode: SSL_ERROR_BAD_CERT_DOMAIN
>>
>> Some older browsers fall back to HTTP, some newer
>> browsers do not fall back to HTTP, and require an
>> exceptions. I dunno how this affects your FFI project
>>
>> and some merits of using GNU Prolog. But somehow projects
>> become quickly outdated, either from the inside or from
>> the outside. I think its an error to think one can make
>>
>> a website, and then forget it for decades, you basically
>> have to internally reviewed it every 2-3 years. So half
>> dead projects like GNU Prolog based on C will disappear
>>
>> in favor to for example Rust projects, simply because
>> Rust might be more attentive and more alive now,
>> until Rust is replaced by the next wave of programming
>>
>> languages. Its the same with repositories that were
>> accessible via FTP and had PS files, nobody can access
>> them easily nowadays. In a few months you might need
>>
>> to place an ai.txt on your website, and add some
>> certificate to it, to prove your code was made by a
>> human and not by a robot, because of cybersecurity
>>
>> and alignment issues.
>>
>> Bye
>>
>
Back to comp.lang.prolog | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
The lost Genius of GNU Prolog FFI Mild Shock <janburse@fastmail.fm> - 2026-08-24 17:03 +0200
The missing genius of Web Prolog (Was: The lost Genius of GNU Prolog FFI) Mild Shock <janburse@fastmail.fm> - 2026-08-24 17:06 +0200
Some variable scoping tricks (Was: The missing genius of Web Prolog) Mild Shock <janburse@fastmail.fm> - 2026-08-24 17:07 +0200
How is "unify" control done in Dogelog Player (Was: The lost Genius of GNU Prolog FFI) Mild Shock <janburse@fastmail.fm> - 2026-08-24 17:26 +0200
csiph-web