You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@royale.apache.org by Harbs <ha...@gmail.com> on 2017/12/18 15:55:43 UTC

internal types in subclasses

I have a class which has an internal class for an Object definition:

class DrawRecord{
	public var rect:Rectangle;
	public var color:uint;
	public var alpha:Number;
	public var columnRect:Rectangle;
}

This class has a subclass which sets one of the properties in this value object (i.e. columnRect). Internal classes are only available in the same file. Is there any trick to make the class definition available to the subclass without making the type definition a full blown public class in its own file?

Thanks,
Harbs

Re: internal types in subclasses

Posted by Alex Harui <ah...@adobe.com.INVALID>.
What makes it hard to define a new type?  Is it something that an IDE can
make easier?  I think for the rest of the tool chain, a file is just a
file and one more file doesn't make a difference.

Regarding reflection data:  The reflection data is designed to disappear
in release builds unless you are using it.  It is currently all or
nothing, but I could imagine that a smarter tool chain could somehow know
to keep some reflection data and not other.  Dynamic classes are not a
recommended practice, IMO, they basically defeat the advantages of AS over
JS.  Proxy-based classes have high overhead, but can deliver something
more like type safety in the hopefully few dynamic situations.

Of course, I could be wrong...
-Alex


On 12/20/17, 1:42 AM, "Harbs" <ha...@gmail.com> wrote:

>I’m not trying to hide anything. It’s just sometimes easier to create
>these types in the class. However, doing that does not make them
>available to subclasses.
>
>Considering that defining types is so important for the goog compiler,
>making it easier to define types would be nice.
>
>In this case, I just made public classes for the types.
>
>Sort of related:
>
>Does it make any sense to have dynamic classes not generate reflection
>data by default? That might make it easier to generate lighter-weight
>value object types.
>
>Harbs
>
>> On Dec 20, 2017, at 9:52 AM, Alex Harui <ah...@adobe.com.INVALID>
>>wrote:
>> 
>> Just wondering, what are you trying to "hide"?
>> 
>> You could make an interface public but not the class that implements the
>> interface.  You would expose the class via some API if you need to.
>> 
>> -Alex
>> 
>> On 12/18/17, 11:38 AM, "Harbs" <ha...@gmail.com> wrote:
>> 
>>> I can’t think of a way. Hence my question… ;-)
>>> 
>>>> On Dec 18, 2017, at 8:19 PM, Alex Harui <ah...@adobe.com.INVALID>
>>>> wrote:
>>>> 
>>>> Not sure.  Is this sort of thing legal in pure AS3?
>>>> 
>>>> -Alex
>>>> 
>>>> On 12/18/17, 7:55 AM, "Harbs" <ha...@gmail.com> wrote:
>>>> 
>>>>> I have a class which has an internal class for an Object definition:
>>>>> 
>>>>> class DrawRecord{
>>>>> 	public var rect:Rectangle;
>>>>> 	public var color:uint;
>>>>> 	public var alpha:Number;
>>>>> 	public var columnRect:Rectangle;
>>>>> }
>>>>> 
>>>>> This class has a subclass which sets one of the properties in this
>>>>> value
>>>>> object (i.e. columnRect). Internal classes are only available in the
>>>>> same
>>>>> file. Is there any trick to make the class definition available to
>>>>>the
>>>>> subclass without making the type definition a full blown public class
>>>>> in
>>>>> its own file?
>>>>> 
>>>>> Thanks,
>>>>> Harbs
>>>> 
>>> 
>> 
>


Re: internal types in subclasses

Posted by Harbs <ha...@gmail.com>.
I’m not trying to hide anything. It’s just sometimes easier to create these types in the class. However, doing that does not make them available to subclasses.

Considering that defining types is so important for the goog compiler, making it easier to define types would be nice.

In this case, I just made public classes for the types.

Sort of related:

Does it make any sense to have dynamic classes not generate reflection data by default? That might make it easier to generate lighter-weight value object types.

Harbs

> On Dec 20, 2017, at 9:52 AM, Alex Harui <ah...@adobe.com.INVALID> wrote:
> 
> Just wondering, what are you trying to "hide"?
> 
> You could make an interface public but not the class that implements the
> interface.  You would expose the class via some API if you need to.
> 
> -Alex
> 
> On 12/18/17, 11:38 AM, "Harbs" <ha...@gmail.com> wrote:
> 
>> I can’t think of a way. Hence my question… ;-)
>> 
>>> On Dec 18, 2017, at 8:19 PM, Alex Harui <ah...@adobe.com.INVALID>
>>> wrote:
>>> 
>>> Not sure.  Is this sort of thing legal in pure AS3?
>>> 
>>> -Alex
>>> 
>>> On 12/18/17, 7:55 AM, "Harbs" <ha...@gmail.com> wrote:
>>> 
>>>> I have a class which has an internal class for an Object definition:
>>>> 
>>>> class DrawRecord{
>>>> 	public var rect:Rectangle;
>>>> 	public var color:uint;
>>>> 	public var alpha:Number;
>>>> 	public var columnRect:Rectangle;
>>>> }
>>>> 
>>>> This class has a subclass which sets one of the properties in this
>>>> value
>>>> object (i.e. columnRect). Internal classes are only available in the
>>>> same
>>>> file. Is there any trick to make the class definition available to the
>>>> subclass without making the type definition a full blown public class
>>>> in
>>>> its own file?
>>>> 
>>>> Thanks,
>>>> Harbs
>>> 
>> 
> 


Re: internal types in subclasses

Posted by Alex Harui <ah...@adobe.com.INVALID>.
Just wondering, what are you trying to "hide"?

You could make an interface public but not the class that implements the
interface.  You would expose the class via some API if you need to.

-Alex

On 12/18/17, 11:38 AM, "Harbs" <ha...@gmail.com> wrote:

>I can’t think of a way. Hence my question… ;-)
>
>> On Dec 18, 2017, at 8:19 PM, Alex Harui <ah...@adobe.com.INVALID>
>>wrote:
>> 
>> Not sure.  Is this sort of thing legal in pure AS3?
>> 
>> -Alex
>> 
>> On 12/18/17, 7:55 AM, "Harbs" <ha...@gmail.com> wrote:
>> 
>>> I have a class which has an internal class for an Object definition:
>>> 
>>> class DrawRecord{
>>> 	public var rect:Rectangle;
>>> 	public var color:uint;
>>> 	public var alpha:Number;
>>> 	public var columnRect:Rectangle;
>>> }
>>> 
>>> This class has a subclass which sets one of the properties in this
>>>value
>>> object (i.e. columnRect). Internal classes are only available in the
>>>same
>>> file. Is there any trick to make the class definition available to the
>>> subclass without making the type definition a full blown public class
>>>in
>>> its own file?
>>> 
>>> Thanks,
>>> Harbs
>> 
>


Re: internal types in subclasses

Posted by Harbs <ha...@gmail.com>.
I can’t think of a way. Hence my question… ;-)

> On Dec 18, 2017, at 8:19 PM, Alex Harui <ah...@adobe.com.INVALID> wrote:
> 
> Not sure.  Is this sort of thing legal in pure AS3?
> 
> -Alex
> 
> On 12/18/17, 7:55 AM, "Harbs" <ha...@gmail.com> wrote:
> 
>> I have a class which has an internal class for an Object definition:
>> 
>> class DrawRecord{
>> 	public var rect:Rectangle;
>> 	public var color:uint;
>> 	public var alpha:Number;
>> 	public var columnRect:Rectangle;
>> }
>> 
>> This class has a subclass which sets one of the properties in this value
>> object (i.e. columnRect). Internal classes are only available in the same
>> file. Is there any trick to make the class definition available to the
>> subclass without making the type definition a full blown public class in
>> its own file?
>> 
>> Thanks,
>> Harbs
> 


Re: internal types in subclasses

Posted by Alex Harui <ah...@adobe.com.INVALID>.
Not sure.  Is this sort of thing legal in pure AS3?

-Alex

On 12/18/17, 7:55 AM, "Harbs" <ha...@gmail.com> wrote:

>I have a class which has an internal class for an Object definition:
>
>class DrawRecord{
>	public var rect:Rectangle;
>	public var color:uint;
>	public var alpha:Number;
>	public var columnRect:Rectangle;
>}
>
>This class has a subclass which sets one of the properties in this value
>object (i.e. columnRect). Internal classes are only available in the same
>file. Is there any trick to make the class definition available to the
>subclass without making the type definition a full blown public class in
>its own file?
>
>Thanks,
>Harbs