[rdnzl-devel] Rdnzl Problem
Iver Odin Kvello
iverodin at gmail.com
Fri Mar 7 16:26:54 UTC 2008
> Maybe you'd like to write a paragraph or two about generic types that we can add to the documentation? (ASCII text is
> fine, doesn't have to be HTML.)
So I've tried writing some documentation for this now finally, here goes:
=== CUT HERE ====
Generic types in RDNZL
In summary, refer to a generic type with type-arguments filled with
a list of type-names like
("System.Collections.Generic.List" "System.Int32")
Motivation
The name of a generic type, when 'closed' with type arguments so it is
instantiable, is of the form
"Basetype´arity[ParameterType1,...,ParameterTypeN]"
and type names of this form can in general be used in all contexts
like the argument to 'NEW' and so forth. However, for this type to be
found, all the parameter types must either lie in the same assembly
as the base type or their names must be assembly-qualified.
Furthermore, the full 'path' to each type would have to be specified
even if their namespaced had been imported with USE-NAMESPACE
making this a bit unpractical.
To solve this, all arguments that accept a string as a typename will
also accept a list of typenames (including sublists for when
type-arguments are themselves generic types) where these lists
represent generic types with their parameters. Also, since the length
of the list is enough to determine the arity of the type, the
"´arity"-part of the type-name can be dropped. Each type-name element
of the list will have its name resolved in the imported namespaces.
The upshot is that for one can instantiate the type with full name
System.Func`2[[System.Int32, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Int32,
mscorlib, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089]], System.Core, Version=3.5.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089
using
(import-assembly "mscorlib") ;; Int32 lives here
(import-assembly "System.Core") ;; Func (of diverse arities) lives here
(use-namespace "System")
(new '("Func" "Int32" "Int32") #'1+)
More information about the rdnzl-devel
mailing list