Re: prefixes and namespaces?
- Posted by Julio C. Galaret Viera <galaret at adin?t.com?uy> Apr 24, 2008
- 681 views
Jeremy Cowgar wrote: > > Ok, another question now about the standard library. > > Currently, two files have been added that are prefixed.... map.e and > datetime.e. > Functions are like: > > }}} <eucode> > include map.e > map m > m = map_new() > m = map_put(m, "name", "John Doe") > puts(1, "Name: " & map_get(m, "name")) > > include datetime.e > datetime dt > dt = datetime_now() > dt = datetime_new(2008, 10, 20, 11, 12, 13) > dt = datetime_add_days(30) > -- ...etc... > </eucode> {{{ > > All function names in these two items thus far: map_new(), map_get(), > map_put(), > map_remove(), map_size(), map_keys(), map_values() and datetime_new(), > datetime_compare(), > datetime_from_date(), datetime_now(), datetime_dow(), datetime_to_unix(), > datetime_from_unix(), > datetime_add_seconds(), datetime_add_days(), datetime_diff_seconds(), > datetime_diff_days(). > Global constants: DT_YEAR, DT_MONTH, DT_DAY, DT_HOUR, DT_MINUTE, DT_SECOND. > > Should we omit the map_ and datetime_ and do things like: > > }}} <eucode> > include datetime.e as dt > > dt:now() > dt:add_days(30) > dt:from_unix(1029382) > > map:put(m, "name", "John") > map:get(m, "name") > </eucode> {{{ > > One concern I have is both map and datetime have the "new" function. Also, > datetime > has datetime_compare, which would become compare(). That does not matter if > you do include with a namespace but... > > Thoughts? > > -- > Jeremy Cowgar > <a href="http://jeremy.cowgar.com">http://jeremy.cowgar.com</a> In my opinion it is not a good idea to prefix those functions. Neither is good to have so many functions like ...add_days, ..add_minutes, weeks, months and so on. It would be enough to have an ADD function where you set the interval (year, month, week, day...): For example, - add 30 days: ..._ADD(DAY, 30, mydate or mydatetime) - add 1 week: ..._ADD(WEEK, 1, mydate or mydatetime) JG