trealla-prolog / trealla

A compact, efficient Prolog interpreter written in plain-old C.
MIT License
254 stars 11 forks source link

feature request: uri library #306

Open matteoredaelli opened 10 months ago

matteoredaelli commented 10 months ago

Hello

Most of the modern programming languages have a uri/url library for managing urls

Also swi prolog has it: an old one written in prolog and a new one written in c

https://www.swi-prolog.org/pldoc/man?section=url https://www.swi-prolog.org/pldoc/man?section=uri

Could you add it to Tralla prolog, please?

Thanks in advance Matteo

infradig commented 10 months ago

Good idea.

On Fri, Aug 25, 2023 at 6:00 PM Matteo Redaelli @.***> wrote:

Hello

Most of the modern programming languages have a uri/url library for managing urls

Also swi prolog has it: an old one written in prolog and a new one written in c

https://www.swi-prolog.org/pldoc/man?section=url https://www.swi-prolog.org/pldoc/man?section=uri

Could you add it to Tralla prolog, please?

Thanks in advance Matteo

— Reply to this email directly, view it on GitHub https://github.com/trealla-prolog/trealla/issues/306, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFNKSEU36B5AS5HQOEGORX3XXBLTHANCNFSM6AAAAAA36EG3O4 . You are receiving this because you are subscribed to this thread.Message ID: @.***>

infradig commented 10 months ago

Implementing parse_url/2 would be a start.

On Fri, Aug 25, 2023 at 6:00 PM Matteo Redaelli @.***> wrote:

Hello

Most of the modern programming languages have a uri/url library for managing urls

Also swi prolog has it: an old one written in prolog and a new one written in c

https://www.swi-prolog.org/pldoc/man?section=url https://www.swi-prolog.org/pldoc/man?section=uri

Could you add it to Tralla prolog, please?

Thanks in advance Matteo

— Reply to this email directly, view it on GitHub https://github.com/trealla-prolog/trealla/issues/306, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFNKSEU36B5AS5HQOEGORX3XXBLTHANCNFSM6AAAAAA36EG3O4 . You are receiving this because you are subscribed to this thread.Message ID: @.***>

infradig commented 10 months ago

Added...

$ tpl
?- parse_url('http://www.xyz.org:81/hello?msg=Hello+World%21&foo=bar#xyz',P).
   P = [search([msg='Hello World!',foo=bar]),protocol(http),host('www.xyz.org'),port(81),path('/hello'),fragment(xyz)].

?- parse_url(U,[search([msg='Hello World!',foo=bar]),protocol(http),host('www.xyz.org'),port(81),path('/hello'),fragment(xyz)]).
   U = 'http://www.xyz.org:81/hello?msg=Hello+World%21&foo=bar#xyz'.
?-

I'll see about the rest.

triska commented 10 months ago

Wouldn't strings be a lot more appropriate for such ephemeral data, like "Hello World!"? There is little chance that other parts of the program need this string (in the sense that it is unlikely to occur anywhere else), and strings can be reclaimed a lot more efficiently on backtracking.

infradig commented 10 months ago

Probably, though they are not created as interned atoms, hence just as easily reclaimed.

On Sun, 27 Aug 2023, 23:18 Markus Triska, @.***> wrote:

Wouldn't strings be a lot more appropriate for such ephemeral data, like "Hello World!"? There is little chance that other parts of the program need this string (in the sense that it is unlikely to occur anywhere else), and strings can be reclaimed a lot more efficiently on backtracking.

— Reply to this email directly, view it on GitHub https://github.com/trealla-prolog/trealla/issues/306#issuecomment-1694667338, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFNKSEQZ53LLRY3ORIC4QTLXXNCKFANCNFSM6AAAAAA36EG3O4 . You are receiving this because you commented.Message ID: @.***>