• Re: Bringing Unicode to Prolog (Dogelog Runtime)

    From Mostowski Collapse@bursejan@gmail.com to comp.lang.prolog on Thu Mar 16 11:54:01 2023
    From Newsgroup: comp.lang.prolog

    Just notice I made a big mistake, or maybe not? I used the following
    syntax for reference data type in Prolog:
    reference :== "0" "r" name .
    Isn’t this in conflict to rational numbers syntax:
    rational :== integer "r" integer .
    Not really a rational number would have a digit after “r”, whereas
    a reference data type wouldn’t have a digit after the “r”.
    Now I can input output the beasts on JavaScript and Python,
    and even sorting them now works:
    ?- sort([1,0rFalse,3.14,0rNone], L).
    L = [3.14, 1, 0rNone, 0rFalse].
    ?- compound(0rTrue).
    fail.
    ?- reference(0rTrue).
    true.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Mostowski Collapse@bursejan@gmail.com to comp.lang.prolog on Thu Mar 16 11:55:36 2023
    From Newsgroup: comp.lang.prolog

    Will also bring them to Java. Although JPL proposes @(null),
    @(false) and @(true)? But the advantage of the 0r syntax,
    it gives a data type, which is not a compound.
    Motivation to introduce these constants. JavaScript wanted
    me a boolean attribute value for the attribute name “disabled”
    on a DOM element. But I guess another application area
    would be JSON parsing and unparsing.
    Mostowski Collapse schrieb am Donnerstag, 16. März 2023 um 19:54:02 UTC+1:
    Just notice I made a big mistake, or maybe not? I used the following
    syntax for reference data type in Prolog:

    reference :== "0" "r" name .

    Isn’t this in conflict to rational numbers syntax:

    rational :== integer "r" integer .

    Not really a rational number would have a digit after “r”, whereas
    a reference data type wouldn’t have a digit after the “r”.
    Now I can input output the beasts on JavaScript and Python,

    and even sorting them now works:

    ?- sort([1,0rFalse,3.14,0rNone], L).
    L = [3.14, 1, 0rNone, 0rFalse].

    ?- compound(0rTrue).
    fail.

    ?- reference(0rTrue).
    true.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Mild Shock@bursejan@gmail.com to comp.lang.prolog on Mon Jul 31 01:00:46 2023
    From Newsgroup: comp.lang.prolog

    Note: Do not confuse multillingual strings, as introduced
    by recent Dogelog Player, with Unicode encoding.
    I am using the phrase "multilingual strings" for a text

    database. Interestingly I managed to make the text
    database declarative. Means the strings/3 entries
    are not order dependent. You can place languages into
    the multifile predicate in any order,

    and it will pick the most specific string independent
    of the order of the strings/3 facts. I was replicating
    the Java Script Resource Bundle lookup on a finer
    grained level, by this simple Prolog code:

    get_string(Key, Locale, Value) :-
    sys_locale_ancestor(Locale, Parent),
    strings(Key, Parent, Res), !,
    Value = Res.

    % sys_locale_ancestor(+Atom, -Atom)
    sys_locale_ancestor(L, L).
    sys_locale_ancestor(L, M) :-
    last_sub_atom(L, P, _, _, '_'),
    sub_atom(L, 0, P, _, M).
    sys_locale_ancestor(_, '').

    The above assumes that locale identifiers use
    underscore separator. It also assumes the last_sub_atom/3
    predicate from Novacore, unfortunatel ISO Core has
    only sub_atom/3, but no last_sub_atom/3.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Mild Shock@janburse@fastmail.fm to comp.lang.prolog on Mon Jul 31 10:06:17 2023
    From Newsgroup: comp.lang.prolog

    For locales, see also:

    Creating global software: Text handling and localization
    in Taligent’s CommonPoint application system
    Mark Davis et al. - 1996
    https://dev.antiguru.de/davis.pdf

    I wasn't sure whether the get_string/3 implementation
    will perform. In Jekejeke Prolog, since it has
    multi-argument indexing, each string/3 lookup with

    mode (+,+,-) will be a little bit faster, whereas
    Doglog Player, which has only first argument indexing
    will use a little bit more time, since it needs

    a scan, can only lookup the Key via an index,
    but will scan for the Parent. If the text database
    isn't extremly large and/or if the locales do

    not have extremly many segments, this is a
    non-issue I guess. And Dogelog Player might get
    multi-argument indexing in the future.

    Mild Shock schrieb:
    Note: Do not confuse multillingual strings, as introduced
    by recent Dogelog Player, with Unicode encoding.
    I am using the phrase "multilingual strings" for a text

    database. Interestingly I managed to make the text
    database declarative. Means the strings/3 entries
    are not order dependent. You can place languages into
    the multifile predicate in any order,

    and it will pick the most specific string independent
    of the order of the strings/3 facts. I was replicating
    the Java Script Resource Bundle lookup on a finer
    grained level, by this simple Prolog code:

    get_string(Key, Locale, Value) :-
    sys_locale_ancestor(Locale, Parent),
    strings(Key, Parent, Res), !,
    Value = Res.

    % sys_locale_ancestor(+Atom, -Atom)
    sys_locale_ancestor(L, L).
    sys_locale_ancestor(L, M) :-
    last_sub_atom(L, P, _, _, '_'),
    sub_atom(L, 0, P, _, M).
    sys_locale_ancestor(_, '').

    The above assumes that locale identifiers use
    underscore separator. It also assumes the last_sub_atom/3
    predicate from Novacore, unfortunatel ISO Core has
    only sub_atom/3, but no last_sub_atom/3.


    --- Synchronet 3.20a-Linux NewsLink 1.114