|Newbie questions about Pliant
I would like to know more about alias in pliant.
|Message posted by mujtaba on 2003/11/23 04:39:32
|Maybe I didn't look hard eneough in the documentation, but
I would like to know more about alias.
I do know that I can use it to alias types, e.g
alias Surface SDL_Surface from "/pligame/SDL.pli"
(SDL_Surface is a type exported from SDL.pli)
What other useful things can I do with it?
Also, I was wondering if I could use alias to simulate namespaces?
e.g I would like to make a type "Surface", but use a prefix like:
var (pligame Surface) screen
var pligame:Surface screen
where somehow (pligame Surface) and pligame:Surface aliased
the SDL_Surface type.
|Message posted by mujtaba on 2003/11/23 04:57:05
|I forgot to ask:
Could I use alias to hide pointers?
e.g can I have "SurfacePtr" alias "Pointer:Surface"?
|Message posted by hubert.tonneau on 2003/11/23 15:12:12
|'alias' is a way to set some new entries in the namespace directory pointing the
same data as some existing ones.
As a result, you can use 'alias' only if the second argument is an identifier,
not an expression. Since 'Pointer' is a function in Pliant, you cannot use 'alias'
On the other hand, if you want to set a new name on an arbitrary data, you can
use 'constant'. Constant will evaluate it's right argument so it can be a
constant SurfacePtr Pointer:Surface
> Also, I was wondering if I could use alias to simulate namespaces?
> var pligame:Surface screen
What you mean here is that 'pligame' is a meta that will get it's first argument
as an identifier, search in a given module, and return the result.
|Message posted by maybe pom on 2003/11/24 06:47:39
|Could be something like:
meta pligame e
var Link:Expression f :> expression duplicate e:0
f module :> pliant_load_module "/pligame/main.pli" the_module:"/pliant/language/basic/safe.pli" 0 this_module
f near f
f compile ?
e suckup f
e set_result f:result f:access
|Message posted by hubert.tonneau on 2003/11/24 08:33:36
|'f near f' seems strange to me. I rather think about 'f near e'
|Message posted by maybe pom on 2003/11/24 09:22:04
|No. "f near f" means that the module lonked to the root of f will be
propagated to the whole f expression. "f near e" would put the module
to which e is linked on the subtrees of f, hence forgeting all about
the wanted module.
The actual problem is that "near" should also accept a module as its argument.
e:module :> m ; e near e
would be equivalent to
e near m