3 ms·
> All Prolog systems before Scryer Prolog use 16 to 24 times as much memory to represent a list of characters. That's not correct. As I said, it's a pretty bas
by tannhaeuser 5y ago
> All Prolog systems before Scryer Prolog use 16 to 24 times as much memory to represent a list of characters.
That's not correct. As I said, it's a pretty basic optimization to store strings as native char buffers, and then only convert to explicit list representation if a variable bound to a string in that way is used in eg unification against a (partial) list, or subjected to a list (or other non-string) builtin. Definitely not new with Scryer Prolog; maybe true of F/OSS Prologs though I doubt it.
- triska 5y agoScryer Prolog does not convert such char buffers to an explicit list representation, they always remain raw bytes. Erlang uses an analogous idea for lists of codes to represent strings. In Scryer Prolog, this pays off especially nicely because the flag double_quotes is set to chars by default; it is one of the few systems in several decades to do this (most other systems currently use the value codes), and therefore this compact internal representation can be easily used in programs, yielding readable strings that can be efficiently processed.