Yeah. That’s what you’ve argued in the past, and in a pure world you’d be right.

However, I’d prefer the option to be practical when dealing with more data 
types. Being forced to fiddle with properly typed objects *always* is too 
confining IMO. What I personally ended up doing when dealing with APIs and the 
like was the make sure to quote everything in my app rather than declare VOs 
even though finding all the instances were a pain.

I think it’s pretty common for folks to use untyped objects *especially* when 
dealing with APIs in classic Flex apps. It seem overly draconian to make that a 
requirement for Royale.

Part of the attraction of ActionScript has been that it’s *optionally* typed. 
Minification in JS makes the optional typing pretty weak.

> If you don't care about SWF support, you can quickly make ValueObjects
> just for the compiler.

Quickly? I’m not sure how.

My $0.02.
Harbs

> On Feb 5, 2018, at 7:28 PM, Alex Harui <[email protected]> wrote:
> 
> IMO, your proposal sort of defeats the purpose of ActionScript and Royale,
> which is to provide a type system at compile time.  Not only should you
> want to address your JSON fields, but you should want to have them
> type-checked, and that you spelled the field name correctly.  Otherwise,
> the compiler is going to also allow you to mistype:
> 
> var name = myProps["nme"];
> 
> 
> And there will be no errors.  And similarly:
> 
> var myObj:Object = {
>  nme: "foo",
>  age : 30.1415
> }
> 
> Will be allowed when it probably shouldn't.  And also, you could then use
> myObj when you intended to use myOtherObj and nobody will know until you
> try to debug in JS.
> 
> 
> If you don't care about SWF support, you can quickly make ValueObjects
> just for the compiler.  In ASDoc, the ValueObject is never instantiated.
> It is just like a typedef for the compiler.
> 
> HTH,
> -Alex
> 
> On 2/5/18, 8:43 AM, "Gabe Harbs" <[email protected]> wrote:
> 
>>> JSON Objects are not destroyed.
>> 
>> Yeah. I know, but untyped js literals are pretty much useless in minified
>> Royale apps.
>> 
>>> Propose a way to determine that a data structure
>>> is external and what the compiler should generate and implement it.
>>> IMO,
>>> the answer is to create ValueObjects.  That is essentially typedefs and
>>> AFAIK, there is no way to automate typedef generation.
>> 
>> I already made a suggestion once:
>> 
>> For untyped Objects, the compiler could convert dot notation to bracket
>> notation.
>> 
>> The other half of that would be to convert all object literals to
>> “quoted” literals automatically.
>> 
>> So if I have a function:
>> 
>> function parseMyJson(json:String):Object{
>>      return JSON.parse(json);
>> }
>> 
>> var myProps:Object = parseMyJson(json);
>> 
>> var name:string = myProps.name;
>> 
>> Would become:
>> 
>> function parseMyJson(json){
>>      return JSON.parse(json);
>> }
>> 
>> var myProps = parseMyJson(json);
>> 
>> var name = myProps["name"];
>> 
>> And this:
>> var myObj:Object = {
>>      name: "foo",
>>      age : 30
>> }
>> 
>> Would become:
>> var myObj = {
>>      "name": "foo",
>>      "age" : 30
>> }
>> 
>> These two features would have solved almost all minification issues I’ve
>> run into.
>> 
>> I’d love to work on this myself, but I’m still not up to making any major
>> changes to the compiler… :-(
>> 
>>> On Feb 5, 2018, at 6:13 PM, Alex Harui <[email protected]> wrote:
>>> 
>>> 
>>> 
>>> On 2/5/18, 2:01 AM, "Gabe Harbs" <[email protected]> wrote:
>>> 
>>>> I’ll try to work on this. It’s pretty slow loading the debug build.
>>>> 
>>>> I still maintain there should be a compiler setting or language feature
>>>> to prevent objects produced from JSON being destroyed on minification.
>>> 
>>> JSON Objects are not destroyed.  The code referencing their fields by
>>> name
>>> has those names changed.  Propose a way to determine that a data
>>> structure
>>> is external and what the compiler should generate and implement it.
>>> IMO,
>>> the answer is to create ValueObjects.  That is essentially typedefs and
>>> AFAIK, there is no way to automate typedef generation.
>>> 
>>> Also, you can turn off minification for the app as a whole.
>>> 
>>> Other ideas welcome,
>>> -Alex
>>> 
>>>> This remains a pain point for developing apps and having to create VOs
>>>> for every API is a drag.
>>>> 
>>>>> On Feb 5, 2018, at 10:21 AM, Alex Harui <[email protected]>
>>>>> wrote:
>>>>> 
>>>>> 
>>>>> 
>>>>> On 2/4/18, 1:10 AM, "Gabe Harbs" <[email protected]> wrote:
>>>>> 
>>>>>> Typo. I meant js-reease.
>>>>> 
>>>>> Yeah, at some later point in time someone should build Value Objects
>>>>> for
>>>>> the JSON and get js-release working.  Maybe after this release.  I'm
>>>>> just
>>>>> trying to make the ASDoc useful.
>>>>> 
>>>>> I'm going to add Events to the class detail page and anchor links from
>>>>> the
>>>>> lists to the details and maybe a simple search-for-class feature,
>>>>> then I
>>>>> think it will be time for a release.
>>>>> 
>>>>> -Alex
>>>>>> 
>>>>>>> On Feb 4, 2018, at 8:08 AM, Alex Harui <[email protected]>
>>>>>>> wrote:
>>>>>>> 
>>>>>>>> 1. Why is bin-release not working?
>>>>>>> 
>>>>>>> Do you mean SWF support?
>>>>>> 
>>>>> 
>>>> 
>>> 
>> 
> 

Reply via email to