View mode: basic / threaded / horizontal-split · Log in · Help
January 21, 2013
dmd json file output
The current version is pretty verbose. For:

    int ***x;

it will emit as the type:

"type" : {
        "kind" : "pointer",
        "pretty" : "int***",
        "targetType" : {
                "kind" : "pointer",
                "pretty" : "int**",
                "targetType" : {
                        "kind" : "pointer",
                        "pretty" : "int*",
                        "targetType" : {
                                "kind" : "int",
                                "pretty" : "int"
                        }
                }
        }
}

I find this to be excessive, and it helps to produce truly gigantic .json files. 
I think it's better to just put out the deco for the type:

"type" : "PPPi"

But, you might say, that is not user friendly! Nope, it isn't. But the .json 
output is for a machine to read, not humans, and the deco types are very space 
efficient, and are trivial to convert to whatever data structure the reader 
needs. Much easier than the verbose thing.

What do you think?
January 21, 2013
Re: dmd json file output
On 2013-01-21 08:27, Walter Bright wrote:
> The current version is pretty verbose. For:

> I find this to be excessive, and it helps to produce truly gigantic
> .json files. I think it's better to just put out the deco for the type:
>
> "type" : "PPPi"
>
> But, you might say, that is not user friendly! Nope, it isn't. But the
> .json output is for a machine to read, not humans, and the deco types
> are very space efficient, and are trivial to convert to whatever data
> structure the reader needs. Much easier than the verbose thing.
>
> What do you think?

Is there any documentation for these, or do we have to find it in the 
compiler sources?

-- 
/Jacob Carlborg
January 21, 2013
Re: dmd json file output
I think there is no problem.

Kenji Hara


2013/1/21 Walter Bright <newshound2@digitalmars.com>

> The current version is pretty verbose. For:
>
>     int ***x;
>
> it will emit as the type:
>
> "type" : {
>         "kind" : "pointer",
>         "pretty" : "int***",
>         "targetType" : {
>                 "kind" : "pointer",
>                 "pretty" : "int**",
>                 "targetType" : {
>                         "kind" : "pointer",
>                         "pretty" : "int*",
>                         "targetType" : {
>                                 "kind" : "int",
>                                 "pretty" : "int"
>                         }
>                 }
>         }
> }
>
> I find this to be excessive, and it helps to produce truly gigantic .json
> files. I think it's better to just put out the deco for the type:
>
> "type" : "PPPi"
>
> But, you might say, that is not user friendly! Nope, it isn't. But the
> .json output is for a machine to read, not humans, and the deco types are
> very space efficient, and are trivial to convert to whatever data structure
> the reader needs. Much easier than the verbose thing.
>
> What do you think?
>
January 21, 2013
Re: dmd json file output
On 1/20/2013 11:50 PM, kenji hara wrote:
> I think there is no problem.

No problem with which scheme?
January 21, 2013
Re: dmd json file output
On 1/20/2013 11:42 PM, Jacob Carlborg wrote:
> Is there any documentation for these, or do we have to find it in the compiler
> sources?


The PPPi is documented in the page on the ABI.
January 21, 2013
Re: dmd json file output
Changing output data to mangled name is no problem. It provides enough
informations for the machine readable.

Kenji Hara


2013/1/21 Walter Bright <newshound2@digitalmars.com>

> On 1/20/2013 11:50 PM, kenji hara wrote:
>
>> I think there is no problem.
>>
>
> No problem with which scheme?
>
>
January 21, 2013
Re: dmd json file output
Am Sun, 20 Jan 2013 23:27:57 -0800
schrieb Walter Bright <newshound2@digitalmars.com>:

> 
> I find this to be excessive, and it helps to produce truly
> gigantic .json files. I think it's better to just put out the deco
> for the type:
> 
> "type" : "PPPi"
> 
> But, you might say, that is not user friendly! Nope, it isn't. But
> the .json output is for a machine to read, not humans, and the deco
> types are very space efficient, and are trivial to convert to
> whatever data structure the reader needs. Much easier than the
> verbose thing.
> 
> What do you think?

How about compressing the json file (lzma)?

Should be just as space efficient, can be easily translated to user
readable output (uncompress), also trivial to read for machines. And it
also compresses the whitespace characters and other text.

https://github.com/D-Programming-Deimos/liblzma
January 21, 2013
Re: dmd json file output
On 1/21/13, Walter Bright <newshound2@digitalmars.com> wrote:
> I think it's better to just put out the deco for the type:
>
> "type" : "PPPi"

It seems the simplest to implement. And core.demangle can be used to
get a string representation, which could eliminate the need for the
'pretty' field?

FWIW the way this is done for C++ typeinfo in .xml files is:

 <Variable id="_4" name="foo" type="_3">
 <PointerType id="_3" type="_2" size="32" align="32"/>
 <PointerType id="_2" type="_1" size="32" align="32"/>
 <PointerType id="_1" type="_0" size="32" align="32"/>
 <FundamentalType id="_0" name="int" size="32" align="32"/>

And then another variable such as PPi would have the type field set to _1.

But it would probably be overkill to try to do this for Json right
now, PPPi is a simple solution.
January 22, 2013
Re: dmd json file output
Would it be reasonable to put an option whether to produce the (too) 
verbose json output or the minimal one?
January 22, 2013
Re: dmd json file output
On 1/21/2013 10:56 PM, ric wrote:
> Would it be reasonable to put an option whether to produce the (too) verbose
> json output or the minimal one?

I'd rather we make a decision.
« First   ‹ Prev
1 2 3
Top | Discussion index | About this forum | D home