Re: dynamic namespaces
- Posted by bernie Sep 04, 2008
- 1129 views
hi bernie, if maps can do what i need then i'll be a happy man.
as an example,
currently we have
--// hardcoded people include person.e as me include person.e as you me:name = "dick" me:print_details() you:name = "harry" you:print_details()
where additional 'persons' would be 'hardcoded' at the head of the program, and each 'person' instance is fixed (cannot be copied to/from, except for individual namespace variables). again i know sequences with offsets could be used, with an additional call to a 'new()' function to create each new object intance
ideally for me, something similar to
--// people created 'on the fly' with own instance variables include person.e as person sequence me = person:[new|dynamic|some other keyword] me:name = "dick" me:print_details() sequence you = person:[new|dynamic|some other keyword] you:name = "harry" you:print_details()
where a copy assignment (me = you) would just overwrite the destination objects namespace local variables.
however, not sure how that would work for variables 'exported' from any file that was used as an include.
all in all, what i'd really like to get away from is my current usage of
1) sequences with index offset to manipulate structures
2) having to pass sequence/structures to functions and using them as return values
do you know if maps can aid with any this?
Here is a simple example of how I think you could do it.
Keep in mine I am very new in using ver 4.0 and this might not work
but its an idea to get you started.
include std/map.e map me = new() map me_details = new() map you = new() procedure print(object m) pretty_print(values(m)) end procedure me = put(me,"name","Joe Doaks") me = put(me,"details",me_details) me = put(me,"print",routine_id("print") call_c_proc(get(me,"print"),{get(me,"details")})