Re:Inner class syntax suggestion

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re:Inner class syntax suggestion

Martin Lafaix

> From: "Dion Gillard" <[hidden email]>
> Mike, how about this as an example of the syntax for inner classes:
<snip>

I don't really like your proposed syntax for the following
reasons:

- It makes no provision for anonymous classes;
- It breaks the current code structure by adding a new construct
  that does not match existing ones (by this I mean the required
  'end [name]' statement);
- No way to define 'static' inner classes without adding yet another
  special case (something like a 'static' keyword that you can only use
  in 'nested' classes);
- ...

So, if inner classes were to be added to NetRexx (which I don't
ask for), I would suggest the following:  adding one (or more)
'pseudo' static methods to the Class class.

For example something like:

  Class.extends(<parent>,[<definitions>],[<interfaces>]) returns Class

with the third (and possibly the first too) parameters optional(s).

<parent> would be either a string or a class (same thing for
<interfaces>) while <definitions> would be strings.

The visibility of the newly defined class would be the one defined by
the corresponding 'properties' statement.

------------
class Fred

  Topping = Class.extends("Object", -
    ["properties indirect;colour = 'red'; taste = 'jam'", -
     "method toString returns String;" -
      "return 'Topping has taste' taste 'and is' colour 'to look at.'"])

  properties indirect
  i
  name
  sandwich = ''

  method eat(s)
    say 'eat the' sandwich
 
  method topMe(t = Topping)
    say t 'is used to fill me up'
------------

I think it integrates seamlessly with existing code, adds no new
concepts/syntax/...  (even the concept of 'pseudo' members is already
there --- see 'length').

Then again, please note I'm not asking for inner classes to be added in
NetRexx (beyond being able to access them, that is).


Martin
--
[hidden email]
Team OS/2
http://wwwi3s.unice.fr/~lafaix/os2.html

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe from this mailing list ( ibm-netrexx ), please send a note to
[hidden email]
with the following message in the body of the note
unsubscribe ibm-netrexx <e-mail address>

Reply | Threaded
Open this post in threaded view
|

Re:Inner class syntax suggestion

dIon Gillard/Multitask Consulting/AU
At 14:31 15/01/98 +0100, you wrote:
>
>I don't really like your proposed syntax for the following
>reasons:
>
>- It makes no provision for anonymous classes;
Why not? The name doesn't have to be there...

>- It breaks the current code structure by adding a new construct
>  that does not match existing ones (by this I mean the required
>  'end [name]' statement);
Hmmm....end [name] is used for loops...and if inner classes are to be put
anywhere in a class, you'll need some way to delimit the class and the
outer one.

>- No way to define 'static' inner classes without adding yet another
>  special case (something like a 'static' keyword that you can only use
>  in 'nested' classes);
Unfortunately, this is the way Java inner static classes work. I'd suggest
it to be the default.

>So, if inner classes were to be added to NetRexx (which I don't
>ask for), I would suggest the following:  adding one (or more)
>'pseudo' static methods to the Class class.
So, you're saying that inner CLASSES should be implemented as a METHOD?
This is a little confusing and inconsistent.

The inner class will get generated by the compiler (javac) as a top level
class anyway...

>class Fred
>
>  Topping = Class.extends("Object", -
>    ["properties indirect;colour = 'red'; taste = 'jam'", -
>     "method toString returns String;" -
>      "return 'Topping has taste' taste 'and is' colour 'to look at.'"])
This looks like a method with an array, rather than a class...and will get
very ugly for large classes.

>I think it integrates seamlessly with existing code, adds no new
>concepts/syntax/...  (even the concept of 'pseudo' members is already
>there --- see 'length').
I think this is extremely confusing: it doesn't look like another class, it
does introduce new syntax for writing code on the programmers behalf.

length? Could you explain how 'length' is a psuedo member?

>Then again, please note I'm not asking for inner classes to be added in
>NetRexx (beyond being able to access them, that is).
I am...I would prefer that NetRexx could do what Java could.


dIon Gillard
Sun Certified Java 1.1 Programmer
Work: http://www.multitask.com.au
NetRexx: http://www.multitask.com.au/netrexx
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe from this mailing list ( ibm-netrexx ), please send a note to
[hidden email]
with the following message in the body of the note
unsubscribe ibm-netrexx <e-mail address>