Re: My scripting language - any suggestions?

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Sun, 31 Aug 2008 11:26:03 +0200

          From comp.compilers

Related articles
My scripting language - any suggestions? licaner@gmail.com (lican) (2008-08-25)
Re: My scripting language - any suggestions? jaluber@gmail.com (Johannes) (2008-08-27)
Re: My scripting language - any suggestions? lerno@dragonascendant.com (=?ISO-8859-1?Q?Christoffer_Lern=F6?=) (2008-08-27)
Re: My scripting language - any suggestions? licaner@gmail.com (lican) (2008-08-29)
Re: My scripting language - any suggestions? jaluber@gmail.com (Johannes) (2008-08-30)
Re: My scripting language - any suggestions? mailbox@dmitry-kazakov.de (Dmitry A. Kazakov) (2008-08-31)
Re: My scripting language - any suggestions? ademakov@gmail.com (Aleksey Demakov) (2008-08-31)
Re: My scripting language - any suggestions? mailbox@dmitry-kazakov.de (Dmitry A. Kazakov) (2008-08-31)
Re: My scripting language - any suggestions? licaner@gmail.com (lican) (2008-08-31)
Re: My scripting language - any suggestions? mailbox@dmitry-kazakov.de (Dmitry A. Kazakov) (2008-09-01)
Re: My scripting language - any suggestions? ademakov@gmail.com (Aleksey Demakov) (2008-09-02)
Re: My scripting language - any suggestions? mailbox@dmitry-kazakov.de (Dmitry A. Kazakov) (2008-09-02)
[7 later articles]
| List of all articles for this month |
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Newsgroups: comp.compilers
Date: Sun, 31 Aug 2008 11:26:03 +0200
Organization: cbb software GmbH
References: 08-08-069 08-08-081 08-08-100
Keywords: OOP, design
Posted-Date: 31 Aug 2008 08:32:26 EDT

On Fri, 29 Aug 2008 08:41:41 -0700 (PDT), lican wrote:


> The OO code is one of my priorities. I think that even the simple
> types like int should have some class for let's say conversion (a = 5;
> a.ToFloat()) and such. It really simplifies some things like
> a.ToFloat().Floor().ToString() all done in one line ;) I know it's an
> extreme example, but I think you get my point.
> ToString(Floor((float)a)) doesn't look so good (or maybe it's also a
> matter of taste). To be honest I never really heard of class clusters,
> but surely I'll look into it.


Prefix notation X.Y is merely a sugar for Y(X), it is not necessarily
related to classes.


The problem with ToFloat etc, is that this is irregular, you have to define
or not to define the conversions between all possible pairs of types. How
are you going to do this? In presence of user-defined types?


In a language with an elaborated types system Integer and Float would have
subtyping relation making explicit conversions unnecessary, for instance
when Integer were a subtype of Float, then it could inherit contravariant
Floor from Float:


      Floor : Integer -> Float (contravariant in the result)


(a bad example, because Floor on integers is an identity function)


Conversion to string is also not that shiny. Actually, from the OO stand
point, it is rather an operation defined on the class Serializable to which
interesting types like Integer belong. This operation should deal with some
object from the class Persistent of which the String type is a member,
TCP_Stream is another, XML_File is yet another etc. Beware, that this
option would require double dispatch.


--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.