1. dynamic namespaces
- Posted by raseu Sep 04, 2008
- 1119 views
euphoria already provides namespaces for data hiding, but would love to see dynamic namespaces in some future release to allow for a slightly more formal oo/class based representation.
example :
reserved keyword : dynamic (auto ?)
include class.person.e as person
sequence people
people = repeat({}, 10) for i = 1 to 10 do people[i] = person:dynamic end for
OR
sequence people = repeat(person:dyamic, 10)
any thoughts?
2. Re: dynamic namespaces : additional
- Posted by raseu Sep 04, 2008
- 1116 views
oops!
which would then allow
some other code ...
person[1]:name = "tom" person[2]:name = "dick" person[3]:name = "harry" etc ...
3. Re: dynamic namespaces
- Posted by mattlewis (admin) Sep 04, 2008
- 1134 views
euphoria already provides namespaces for data hiding, but would love to see dynamic namespaces in some future release to allow for a slightly more formal oo/class based representation.
example :
-- reserved keyword : dynamic (auto ?) -- reserved functions : constructor(), destroy() include class.person.e as person sequence people people = repeat({}, 10) for i = 1 to 10 do people[i] = person:dynamic end for
OR
sequence people = repeat(person:dyamic, 10)
any thoughts?
First thought: the <eucode> tag makes it easier to read posted code.
It's not clear to me what this code does.
Previously, I think we had a longer term roadmap than 4.0, though maybe it was just talk...But my recollection (or maybe just my recommendation) was that some form of OO be targeted for 5.0 or thereabouts.
Matt
4. Re: dynamic namespaces
- Posted by raseu Sep 04, 2008
- 1133 views
yep <eucode> does make it easier to read, but that was my first ever post, did'nt read the Creole Help!
don't know myself what the dev roadmap is, but hopefully some kind of 00/dynamic module at some time in future would be great.
so,
1) would ideally like to have collections of objects without having to reference items via sequence index/offset. particularly complex objects (ie: 'C' to euphoria structs)
2) currently, for each object that uses a common module function, passing in the object as an extra parameter to modify it seems to be the most obvious/cleanest way to modify the object.
predeclaring each object into its own namespace
include person.e as tom include person.e as dick include person.e as harry
is impractical/unusable when interfacing to a 'C' library that returns a dynamic length list of structures
again, i know that we can create sequences and offsets, but i believe that a dynamic namespace would be the ideal.
it would provide for a far cleaner interface for managing objects, where each dynamic instance would have obviously have its own copies of module global vars, and shared procedures/functions, which in many cases for me would also do away with the need for pass by reference
apart from my gripes, it's still a great language, one of the few that allows me to 'code while thinking'
5. Re: dynamic namespaces
- Posted by bernie Sep 04, 2008
- 1134 views
yep <eucode> does make it easier to read, but that was my first ever post, did'nt read the Creole Help!
don't know myself what the dev roadmap is, but hopefully some kind of 00/dynamic module at some time in future would be great.
so,
1) would ideally like to have collections of objects without having to reference items via sequence index/offset. particularly complex objects (ie: 'C' to euphoria structs)
2) currently, for each object that uses a common module function, passing in the object as an extra parameter to modify it seems to be the most obvious/cleanest way to modify the object.
predeclaring each object into its own namespace
include person.e as tom include person.e as dick include person.e as harry
is impractical/unusable when interfacing to a 'C' library that returns a dynamic length list of structures
again, i know that we can create sequences and offsets, but i believe that a dynamic namespace would be the ideal.
it would provide for a far cleaner interface for managing objects, where each dynamic instance would have obviously have its own copies of module global vars, and shared procedures/functions, which in many cases for me would also do away with the need for pass by reference
apart from my gripes, it's still a great language, one of the few that allows me to 'code while thinking'
In my opinion that could all be very easily accomplished
by using maps in ver 4.0
bernie
6. Re: dynamic namespaces
- Posted by mattlewis (admin) Sep 04, 2008
- 1194 views
yep <eucode> does make it easier to read, but that was my first ever post, did'nt read the Creole Help!
don't know myself what the dev roadmap is, but hopefully some kind of 00/dynamic module at some time in future would be great.
I'm not sure what you mean by dynamicif I had said it, I'd mean some sort of eval capability. If that's true, then it is definitely in my mental roadmap.
I actually implemented both OO and dynamic code in ooeu, though I only ever got around to implementing the dynamic code for the eu-in-eu interpreter. The C-backend for ooeu doesn't support this.
Matt
7. Re: dynamic namespaces
- Posted by raseu Sep 04, 2008
- 1118 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?
8. Re: dynamic namespaces
- Posted by bernie Sep 04, 2008
- 1130 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")})