Re: My scripting language - any suggestions?

Johannes <jaluber@gmail.com>
Sat, 30 Aug 2008 03:53:57 -0700 (PDT)

          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)
[8 later articles]
| List of all articles for this month |
From: Johannes <jaluber@gmail.com>
Newsgroups: comp.compilers
Date: Sat, 30 Aug 2008 03:53:57 -0700 (PDT)
Organization: Compilers Central
References: 08-08-069 08-08-081 08-08-100
Keywords: interpreter, OOP
Posted-Date: 30 Aug 2008 16:36:32 EDT

On Aug 29, 5:41 pm, lican <lica...@gmail.com> wrote:
> Also forgot to write
> that I am in fact planning to do something like
> "a.is_array();" (almost pure OO). The same for strings and any other
> class:


If you create an array class (like in .NET), you can write
a.Is(Array), too. Would be more consistent and can be expanded to
cover similar cases (like b.Is(Complex<T>) or b.Is(Complex<float>)).
...
> 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.


You could create a conversion operator "to" instead using "ToClass"
functions. Then pipelining would go like:


a to Float.Floor() to String


Hmm... The dot is disturbing the aesthetics here, but one can only use
a different way to declare an method invocation to get rid of it. Then
you would have to remove the dot in general or live with two
equivalent ways to do calls. Or it could be that the syntax is just
unfamiliar. Anyway, the advantage of the "to" keyword would be that
you wouldn't write "((MyObject) object).Calculate()" like in C#/Java,
but could write "object to MyObject.Calculate()". You directly know
which expression is converted and don't have to add some extra
parentheses just to get the priorities right. Also, if the expression
is a bit longer, you don't have to memorize the entire thing at once
or that the closing parenthesis still belongs to the conversion. That
being said, you haven't specified how you do cast objects in your
language, so I simply speculate.


Johannes


Post a followup to this message

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