| Did you know ... | Search Documentation: |
| Pack logtalk -- logtalk-3.103.0/coding/ai/skills/logtalk-portability/SKILL.md |
name: logtalk-portability description: Write Logtalk code portable across Prolog backends. Use when implementing libraries or applications that must run on multiple systems, reviewing non-portable constructs, or isolating backend-specific code. license: Apache-2.0 metadata: copyright: "2026 Paulo Moura <pmoura@logtalk.org>" ---
Write code that runs on any supported Prolog backend. Prefer Logtalk built-ins and ISO Prolog; isolate anything else behind a portable interface.
Portability across all supported backends is a hard requirement unless the user explicitly narrows it. Do not introduce backend-only solutions even as temporary experiments without that approval.
portability flag and linter: handbook compiler flags / linter sections
Do not duplicate the handbook. Link for detail.unknown or double_quotes
Behavior must not assume a particular value of these flags. Code that only works for one setting is non-portable."..." terminals/non-terminals in grammar rules; their meaning varies with double_quotes and across systems. Prefer explicit representations (e.g. lists of character codes or chars via portable APIs, or Logtalk/library helpers) that do not rely on that flag.current_logtalk_flag(prolog_dialect, Dialect) (or related flags) only inside those isolated entitiesânot scattered through the appEnable portability checking while developing portable code:
| ?- set_logtalk_flag(portability, warning).
(or pass portability(warning) in logtalk_load/2). Treat non-portable built-in / arithmetic warnings as issues to fix or encapsulate.
0'X) or decimal numbers instead of `16'...` numeric notation.layout_inside_quotes.| Goal | Prefer |
|---|---|
| Lists, types, OS paths, random, ⦠| Logtalk libraries + uses/2 |
| Backend differences | Protocol + small implementing objects; conditional compilation only there |
| Settings per backend | Conditional compilation in settings.lgt, not in core logic |
| Strings / text in grammars | Representations independent of double_quotes; no "..." in DCG bodies for portable code |
| Flags | Do not rely on unknown or double_quotes; avoid other non-standardized flag assumptions |
library(...), SICStus libraries, or any backend module as a dependency of portable codedouble_quotes is codes, chars, or atomunknown is error, warning, or fail:- if(current_logtalk_flag(prolog_dialect, ...)) through business logic instead of isolating itportability linter warnings without encapsulation or replacementportability(warning) cleanly, or only with documented encapsulated exceptionsunknown or double_quotes flag values