Re: prefixes and namespaces?

new topic     » goto parent     » topic index » view thread      » older message » newer message

Julio C. Galaret Viera wrote:
> 
> 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)

While I recognize the potential for this devolving into a religious war, I
concur.  Maybe we need a description for referencing legacy concepts.  BASIC-y
was used in a prior message.  The above is decidedly SPREADSHEET-y.

Numeric functions on spreadsheets are (nicely) overloaded, IMO.  

As far as a descriptor goes, I have always been partial to moment.  It is
shorter than datetime, yet communicates that "it" is something different from
either a date or a time.  It is also part of the vernacular, as one has probably
used the expression "precise moment in time" before.

It has the distinct disadvantage of never having been used in programming,
thereby making me think others have gone down this path and rejected its use. 
Probably because one of the definitions of moment is that it can be used to
reference a span of time rather than an instant (and hence the need for the
expression PRECISE moment).

Mike

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu