Luis M. Gonzalez | 28 Jan 22:07

Re: method names

No, I'm not asking to have a class library for Boo besides .Net's one.
What I ask myself is if there is a way to use the same classes but by typing 
the method names differently.

Following the same example: upper() is equivalent to ToUpper()
In the same way, there might be many other methods in Python's and .Net's 
clase that are equivalent and produce the same behaviour.
What I'm wondering is whether it would be possible (or desirable) to use the 
"ToUpper()" method of the .NET's string class by simply typing "upper()" as 
I would if I were programming in Python.

Another example:
For getting the type of "a" I type: "a.GetType()", which is equivalent to 
"type(a)" in Python.

In this case I could write the following function to make them equivalent:

def type(i as object):
        return i.GetType()

The questions are:
- Is there a way to make this function built-into Boo?
- And if posible, is there any inconvenience in doing so?
- And finally, would it be desirable?

----- Original Message ----- 
From: "Ayende Rahien" <Ayende@...>
To: <user@...>
Sent: Friday, January 28, 2005 5:06 PM
Subject: RE: [boo-user] method names
(Continue reading)

Ayende Rahien | 28 Jan 22:29

RE: method names

> No, I'm not asking to have a class library for Boo besides .Net's one.
> What I ask myself is if there is a way to use the same classes but by
> typing
> the method names differently.

Do read Greg Fitzgerald's reply, especially the part about ruby.
I'm sure that there is a way to do this (probably inserting some custom step
to the compiler pipeline which can "add" methods to types on the fly.

Actually, that wouldn't be such a bad idea in the first place.
You might have a convention of type and typeOuterMethods and have a compiler
step to translate any unknown method on type to the equilent method on
typeOuterMethods.

In fact, Fowler would positively love it :-)
It should be an interesting project, if nothing else, and extensible to
outer areas.
Can any one the compiler knowledgable tell us if this is indeed possible?

> Following the same example: upper() is equivalent to ToUpper()
> In the same way, there might be many other methods in Python's and .Net's
> clase that are equivalent and produce the same behaviour.
> What I'm wondering is whether it would be possible (or desirable) to use
> the
> "ToUpper()" method of the .NET's string class by simply typing "upper()"
> as
> I would if I were programming in Python.
> 
> Another example:
> For getting the type of "a" I type: "a.GetType()", which is equivalent to
(Continue reading)

Greg Fitzgerald | 28 Jan 22:46

Re: method names

> - Is there a way to make this function built-into Boo?
no doubt it's possible.

> - And if posible, is there any inconvenience in doing so?
takes time and adds a maintenance dependency on another language which
Boo has no control over.

> - And finally, would it be desirable?
Besides the obvious difference in capitalization that would make the
code look inconsistent, if you were to decide to make the language
Python-friendly, you'd probably want to find equivalents for all the
Python methods (for all the built-in types anyhow).  While this is
trivial for mapping upper() to ToUpper(), not all the Python methods
don't all have .NET equivalents.  For example, compare Python's
split() method and to the various .NET Split() overloads.

Greg


Gmane