Replies: 4 comments 4 replies
-
With the express understanding that I base this on some conjectures, I'd like to see how this can work from my perspective. Just something to start with. Namespaced entity definitionIf we consider that a [default] definition of an entity may contain a namespace, then perhaps something like this can work. Term-based:- object((ns, obj)).
:- end_object. :- object(ns-obj).
:- end_object. :- object(ns:obj). %% too much of a clash with Prolog modules?
:- end_object. Relation/property-based:- object(obj, namespace(ns)).
:- end. Loading into a namespaceOverridinglogtalk_load(Files, [namespace(myns)]) Mappinglogtalk_load(Files, [namespaces(ns-myns)]) Using a namespaced entityFully-qualified(ns, obj)::message.
ns-obj::message. Imported:- uses_namespace(ns).
pred :- obj::message. Standard library
|
Beta Was this translation helpful? Give feedback.
-
Another possible solution is to introduce variants of the reflection predicates that take an additional namespace argument. The existing predicates (and the applications using them) would continue to work in all cases where a single/default namespace is used at runtime. As an example, a I would prefer to avoid non-namespaced entities and instead have e.g. |
Beta Was this translation helpful? Give feedback.
-
We also need syntax for sending a message to an object qualified by a namespace. For example: ?- ns/obj::message. Here, using the ?- ns:obj::message. |
Beta Was this translation helpful? Give feedback.
-
The :- object(...).
:- uses([system/list]).
foo :-
list::member(..., ...).
:- end_object. |
Beta Was this translation helpful? Give feedback.
-
Currently, Logtalk provides a single, flat namespace for all entities (objects, protocols, and categories). This results in the potential of name conflicts, notably between Logtalk development and application developers. For example, adding a new library to the Logtalk distribution can result in a name clash with a third-party application library. Two independent contributors can publish libraries using the same name for some entities, preventing using both libraries in the same application. Supporting multiple namespaces can help minimizing these name conflicts.
Implementing support for multiple namespaces requires new and updated language constructs, new syntax, and significant changes to the reflection API and developer tools. It's not clear that backwards compatibility can be preserved, even if support for a default namespace is provided. The tentative plan is to include support for multiple namespaces in the next generation (4.x) of Logtalk.
Ideal goals
Optional feature
It should be possible to write simple applications without forcibly defining a new namespace.
Default namespace
There should be a default namespace, used when the loaded code doesn't include any namespace declarations.
Load code to a given namespace
It should be possible to load code doesn't include any namespace declarations into a (non-default) namespace.
Namespace aliases
Similar to what's already supported for entities and predicates, it should be possible to define an alias for a namespace, notably as a solution to shorten the name of long namespaces.
Beta Was this translation helpful? Give feedback.
All reactions