Date classes

Philippe Marschall philippe.marschall at gmail.com
Wed Apr 18 07:30:45 UTC 2007


2007/4/17, Hernan Wilkinson <hernan.wilkinson at gmail.com>:
>
>
> On 4/17/07, Philippe Marschall <philippe.marschall at gmail.com> wrote:
> > You said:
> > > 5) Chalten is based on a arithmetic model that allows you to represent
> time measurements easily (like 3 days, 5 months, etc)
> >
> > So I assumed you meant we could write
> > 5 months
> > just the same way we could write
> > 100 dollars
> > like the examples in the paper show.
>
> No "5 months" but "5 * months" or "moth with: 5". Same for "dollars",
> "euros", "meters", "liters", "A", "B", etc.
> That is why I think that measure was not a good word to define this
> objects... 5*A is not a measure.. what we implemented is really an algebra,
> maybe a limited one, but an algebra at the end.

Maybe I'm just seeing things:
http://www.iam.unibe.ch/~ducasse/Teaching/CoursAnnecy/0506-M1-COO/A%20New%20Object-Oriented%20Model%20of%20the%20Gregorian%20Calendar.pdf
page 7, figure 11:
14 days + 1 week = 1814400000 milliseconds. "Adding measurements of
the same base unit"
((14 days + 1 week) convertTo: days) = 21 days. "Converting the result
of an operation"
(1 year + 10 days) = (1 year + 10 days) "Adding measurements of
different base unit"
10 years * 10 = 100 years "Multiplying a measurement by a number"
10 years * 12 months = 10 year*year "Multiplying measurements"
10 years * 12 months / 24 months = 5 years "The model automatically
simplifies units"
100 kilometers / 1 hour "Represents a speed of 100 km per hour"
0.01 / 1 month "Represent an interest rate of 10 % by month"

page 8, figure 12:
(GregorianYear number: 2005) next: 1 year "Returns GregorianYear number: 2006"
(GregorianYear number: 2005) next: 12 months "Returns GregorianYear
number: 2006"
(GregorianYear number: 2005) next: 10 years "Returns GregorianYear number: 2015"
(GregorianYear number: 2005) previous: 5 years "Returns GregorianYear
number: 2000"

page 8, figure 13:
(GregorianYear number: 2005) next: 120 days "Signals an exception
because 120 days can not be
converted to years"
'01/2005' asGregorianMonthOfYear next: 120 days "Signals an exception
because 120 days can not be
converted to months"

page 8, figure 14:
GregorianDay monday next: 4 days "Returns Friday"
GregorianMonth january next: 2 months "Returns March"
(GregorianMonth january dayNumber: 1) next: 2 days "Returns January 3rd "

page 8, figure 17:
"Returns an Interval with six elements, the years
2005,2007,2009,2011,2013 and 2015 inclusive".
(GregorianYear number: 2005) to: (GregorianYear number: 2015) by: 2 years
"Returns an Interval with six elements, the years
2005,2004,2003,2002,2001 and 2000 inclusive".
(GregorianYear number: 2005) to: (GregorianYear number: 2000) by: -1 year

page 10, figure 22:
"06/01/2005 is a Thursday"
aTimespan := Timespan from: '06/01/2005' asGregorianDate duration: 48 hours.



> > > > And there is still the question where year comes from
> > > > (please no shared pool).
> > >
> > > I did not see that question, but the answer is No.  The variable "year"
> is
> > > global. The same as month, day, January, February, Monday, etc. Maybe
> you
> > > will not like it,
> >
> > Global state sucks, no matter how well intended. I haven't tested it
> > but I wouldn't be surprised if it causes problems with Monticello.
>
> Well, I do not agree... I used to think like that but I've changed my
> mind... Object should be global if the entity they represent in real life is
> global... but I understand that you don't like them.
> From an Software Engineering point of view, global variables are not good...
> but if you think software development as a learning process and you see the
> Smalltalk image as the "state" of your knowledge about a specific domain(s),
> having global objects (well know objects) is not bad....
>
> > > but I think that the time domain is so important in
> > > writing software as the arithmetic domain,
> >
> > I think time sucks as a domain. Days that don't have 24 hours, minutes
> > that don't have 60 seconds, years that don't have 365 days, different
> > calendars, timezones, points in time with timezones and without
> > timezones, timezones with more than two DST changes, different week
> > start days, .... For every rule there's an exception and these can
> > change at basically any time. Seriously, how much worse can it get?
>
>
> I believe it is a really interesting domain!!  because of the things you
> mention! because the exceptions it has makes it a very interesting and
> challenging problem to design.

Well, yeah. I just don't see how Chalten addresses many of these. Eg.
it assumes days have 24 hours and minutes have 60 seconds.

> > > so if numbers are global (1, 2,
> > > 3, etc) why not the time objects? They are well know entities of the
> real
> > > life....
> >
> > Numbers are literals not global variables.
>
> Well... that's an implementation detail... at the end they are global. They
> are not "global variables" but "global objects" because the parser knows
> about them.... so, at the end, they are global. And I think it is ok for
> them to be global because it is almost impossible to think about a
> programming language without numbers.... when we get a programming language
> we are expecting to have at least the math to be model with it... (a
> programming language without numbers as primitives is a very challenging
> idea... I don't know if it is feasible...)

I don't agree because they don't have the semantics of globals like
identify (for everything but SmallIntegers). The compiler/parser knows
about them, that's all. But that certainly depends of POV.

> Anyhow, I think that when your knowledge about a problem domain (Smalltalk
> image) is mature, you will end up with some global objects... We develop
> financial software and I have to tell you that having "dollar", "euro", etc.
> as global objects would help us a lot...   for example no need to declare them
> on each unit test (of course we use test resources, but still), no need for
> the final user to define them (they expect dollar, euro, peso, etc. as part
> of the "kit")...

Why don't you have them as global objects then?

Cheers
Philippe

> Bye,
> Hernan.
>
> > Cheers
> > Philippe
> >
> > > Bye,
> > > Hernan.
> > >
> > >
> > > > Cheers
> > > > Philippe
> > > >
> > > > >
> > >
> http://portal.acm.org/citation.cfm?id=1094964&coll=ACM&dl=ACM&CFID=20205775&CFTOKEN=19800555
> > > > > )
> > > > >
> > > > > Hope this help.
> > > > > Hernan.
> > > > >
> > > > > > Cheers
> > > > > > Philippe
> > > > > >
> > > > > > > > > These objects are
> > > > > > > > > polymorphic with numbers respect to the arithmetic messages
> such
> > > as
> > > > > +,
> > > > > > > -, *,
> > > > > > > > > etc., that means that you can use them in arithmetic
> formulas
> > > > > > > >
> > > > > > > > That's true to a certain extent in Chronos for example you
> can:
> > > > > > > > Timepoint now - (CalendarDuration months: 1)
> > > > > > > > (CalendarDuration months: 1) * 5
> > > > > > > > but you can't:
> > > > > > > > 5 * (CalendarDuration months: 1)
> > > > > > >
> > > > > > > Ok, but it is not only the functionality what it is important
> for
> > > us...
> > > > > for
> > > > > > > us it is also important the way you "write" these things... for
> > > example,
> > > > > > > with Chalten/Aconcagua you can write:
> > > > > > >
> > > > > > > 5 * month ---> Equivalent to 5 * (CalendarDuration months: 1)
> > > > > > > 5 * meter / (second * second) --> A measure of acceleration if
> you
> > > > > create
> > > > > > > meter as a unit using Aconcagua
> > > > > > > 1/10 * year --> Represents an interest rate of 10% yearly.
> > > > > > >
> > > > > > > As you can see, time measure are not only related only to the
> time
> > > > > domain
> > > > > > > but used in other domains... that is way for us it is important
> to
> > > > > support
> > > > > > > this type of behavior and in a DSL way...
> > > > > > >
> > > > > > > Bye,
> > > > > > > Hernan.
> > > > > > >
> > > > > > > > > 5) And of course, I like Chalten's model more that Chronos
> :-).
> > > For
> > > > > me
> > > > > > > it is
> > > > > > > > > easier to use, but this is just a matter of taste...
> > > > > > > > >
> > > > > > > > > There is a paper we wrote 2 years ago about the problems
> that
> > > the
> > > > > > > Smalltalk
> > > > > > > > > date classes have and the advantages of having a better
> model.
> > > If
> > > > > you
> > > > > > > are
> > > > > > > > > interested on having better date and time classes, I
> recommend
> > > you
> > > > > to
> > > > > > > read
> > > > > > > > > the paper... you may not like it, but at least you will see
> > > other
> > > > > people
> > > > > > > > > ideas...
> > > > > > > > > We use that model (Chalten) in a production system and we
> > > believe it
> > > > > > > allowed
> > > > > > > > > us to avoid many common mistakes related to financial
> > > systems....
> > > > > but
> > > > > > > hey,
> > > > > > > > > that's just a feeling, nothing I can prove formally.
> > > > > > > > >
> > > > > > > > > I hope you can do something useful.
> > > > > > > > > Bye,
> > > > > > > >
> > > > > > > > Chronos is a bit ugly in Squeak because Squeak does not
> support
> > > > > > > > namespaces which means that classes that model the same
> concept as
> > > > > > > > Squeak Chronology classes have different names (unless you
> mess
> > > with
> > > > > > > > shared pools). Also loading it is a bit of a pain with
> Monticello
> > > > > > > > (this is the fault of Monticello and not Chronos).
> > > > > > > >
> > > > > > > > Cheers
> > > > > > > > Philippe
> > > > > > > >
> > > > > > > > > Hernan.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > On 4/16/07, J J <azreal1977 at hotmail.com > wrote:
> > > > > > > > > > I have looked at Cronos but it is really huge, and the
> classes
> > > > > that
> > > > > > > come
> > > > > > > > > > with the image are already very close.  I will have to
> look at
> > > > > > > Chalten,
> > > > > > > > > but
> > > > > > > > > > what is wrong with a few upgrades to the classes that come
> > > with
> > > > > > > Squeak?
> > > > > > > > > >
> > > > > > > > > > >From: "Hernan Wilkinson" < hernan.wilkinson at gmail.com>
> > > > > > > > > > >Reply-To: The general-purpose Squeak developers
> > > > > > > > > > >list<
> squeak-dev at lists.squeakfoundation.org
> > > >
> > > > > > > > > > >To: "The general-purpose Squeak developers
> > > > > > > > > > >list"<
> squeak-dev at lists.squeakfoundation.org
> > > >
> > > > > > > > > > >Subject: Re: Date classes
> > > > > > > > > > >Date: Mon, 16 Apr 2007 14:28:09 -0300
> > > > > > > > > > >
> > > > > > > > > > >Before doing something with Date, I recommend you to take
> a
> > > look
> > > > > at
> > > > > > > > > > >"Chalten" or "Cronos". Chalten is in SqueakSource.... I
> think
> > > > > Cronos
> > > > > > > too.
> > > > > > > > > > >
> > > > > > > > > > >Hernan.
> > > > > > > > > > >
> > > > > > > > > > >On 4/16/07, J J < azreal1977 at hotmail.com> wrote:
> > > > > > > > > > >>
> > > > > > > > > > >>Hi all,
> > > > > > > > > > >>
> > > > > > > > > > >>I am doing some stuff with dates and I noticed the date
> > > classes
> > > > > that
> > > > > > > > > come
> > > > > > > > > > >>with the default Squeak image are very nice and very
> close
> > > to
> > > > > having
> > > > > > > > > > >>everything I would want.  But there are a few
> > > inconsistencies
> > > > > here
> > > > > > > and
> > > > > > > > > > >>there, and things missing that would make things easier.
> > > > > > > > > > >>
> > > > > > > > > > >>So what is the procedure to updating this?  I think it's
> > > part of
> > > > > the
> > > > > > > > > core
> > > > > > > > > > >>system so I probably can't just do a monicello package
> > > update
> > > > > > > > > > >>somewhere?  Do
> > > > > > > > > > >>I have to do it through mantis?
> > > > > > > > > > >>
> > > > > > > > > > >>Thanks,
> > > > > > > > > > >>Jason
> > > > > > > > > > >>
> > > > > > > > > >
> > > > > > > > >
> > > > > > >
> > > > >
> > >
> >>_________________________________________________________________
> > > > > > > > > > >>Download Messenger. Join the i'm Initiative. Help make a
> > > > > difference
> > > > > > > > > today.
> > > > > > > > > >
> > > > > > > > >
> > > > > > >
> > > > >
> > > >>
> http://im.live.com/messenger/im/home/?source=TAGHM_APR07
> > > > > > > > > > >>
> > > > > > > > > > >>
> > > > > > > > > > >>
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > >
> > > > >
> > >
> _________________________________________________________________
> > > > > > > > > > Get a FREE Web site, company branded e-mail and more from
> > > > > Microsoft
> > > > > > > Office
> > > > > > > > > > Live!
> > > > > > > > >
> > > > > > >
> > > > >
> > >
> http://clk.atdmt.com/MRT/go/mcrssaub0050001411mrt/direct/01/
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> > >
> > >
> > >
> >
> >
>
>
>
>
>



More information about the Squeak-dev mailing list