Using a namespace (@-syntax) without defining it (@=-syntax) causes it to be undefined
For example, specifying that an
ID
from theTypeName()
namespace can be used (@
-syntax), without ever specifying somewhere where it may be defined (@=
-syntax) causes the namespace to be excluded fromanalysis-auto.generated.str
. E.g. by specifying:TypeName@ID -> Type {"CustomType"}
This causes errors if, for example, one wants to add pre-defined types, but not provide the ability to create custom types.
Submitted by D. Pelsmaeker on 31 May 2012 at 17:30adjust-index-lookup(target |namespace, path, prefix): CustomType(<target>) -> [ Def([TypeName(), "MyType"]), Def([TypeName(), "AnotherType"]), [TypeName() | path] ]
Issue Log
Can you please explain why you need predefined types in a reference mechanism? I can imagine that you want predefined types in type checking. But why do you need to resolve to predefined types? What is the expected behaviour of resolving a reference which has no definition site?
It is a common use case to have some special types (e.g.
Int
,Boolean
) in addition to the types that are defined. These special types are never defined explicitly. By including those types manually in the namespace the code completion and type checking support these types without extra work. Now this example is the same case but without the ability to define custom types, so only the pre-defined types are available. It will be easy to add the ability to define custom types in the future.Without the ability to define custom types, resolving to predefined types still ensures that there is only one definition (my special predefined definition) that such a type refers to. Then the later code generation phase can deal with those types.
By the way, this was just an example. In general, when for any reason someone specifies a namespace use (
@
), the namespace should be defined, allowing it to be manipulated. Another example would be resolving to a predefined variable that always exists, allowing it to be used like any other variable. Or a predefined set of functions without the ability to add your own.
This is related to the old SDF annotations for name bindings. Use NBL instead.
Log in to post comments