January 23, 2013
On 1/23/13 2:41 AM, Jacob Carlborg wrote:
> On 2013-01-22 20:53, Sönke Ludwig wrote:
>
>> Consider "int[4u] delegate(scope float*[void function(scope int)] p1,
>> Rebindable!(const(C))*[]* b)"
>>
>> There are actually quite some things to parse in human readable type
>> strings, I even remember some
>> expressions. And parsing this is at least as language specific as the
>> mangled name. But I agree that
>> having both should be a good compromise.
>
> This wouldn't be fun to parse. It basically requires a front end.

If we need a secondary parser to slice and dice the json output, we failed producing good json output.

Andrei

January 23, 2013
On 2013-01-23 08:58, Andrei Alexandrescu wrote:

> If we need a secondary parser to slice and dice the json output, we
> failed producing good json output.

That's what I'm saying. Just use what Rainer suggested:

"type" : {
    "mangled" : "PPPi",
    "pretty" : "int***",
}

-- 
/Jacob Carlborg
January 23, 2013
On 1/23/13 11:07 AM, Jacob Carlborg wrote:
> On 2013-01-23 08:58, Andrei Alexandrescu wrote:
>
>> If we need a secondary parser to slice and dice the json output, we
>> failed producing good json output.
>
> That's what I'm saying. Just use what Rainer suggested:
>
> "type" : {
> "mangled" : "PPPi",
> "pretty" : "int***",
> }

Yes please. Err on the side of verboseness as long as filtering out the unnecessary output is easy.

Andrei

January 23, 2013
On 01/23/2013 05:07 PM, Jacob Carlborg wrote:
> On 2013-01-23 08:58, Andrei Alexandrescu wrote:
>
>> If we need a secondary parser to slice and dice the json output, we
>> failed producing good json output.
>
> That's what I'm saying. Just use what Rainer suggested:
>
> "type" : {
>      "mangled" : "PPPi",
>      "pretty" : "int***",
> }
>

That still requires at least one of two secondary parsers.
January 23, 2013
On 2013-01-23 18:09, Timon Gehr wrote:

> That still requires at least one of two secondary parsers.

Technically yes, but there's already a demangler available in Phobos/druntime.

-- 
/Jacob Carlborg
January 23, 2013
On 1/23/2013 12:02 PM, Jacob Carlborg wrote:
> On 2013-01-23 18:09, Timon Gehr wrote:
>
>> That still requires at least one of two secondary parsers.
>
> Technically yes, but there's already a demangler available in Phobos/druntime.


Yup. The "pretty" attribute is completely redundant.
January 23, 2013
On Wednesday, 23 January 2013 at 20:02:36 UTC, Jacob Carlborg wrote:
> On 2013-01-23 18:09, Timon Gehr wrote:
>
>> That still requires at least one of two secondary parsers.
>
> Technically yes, but there's already a demangler available in Phobos/druntime.

Not every program using the json output will be in D (especially IDEs).

NMS
January 24, 2013
On 2013-01-23 22:38, Nathan M. Swan wrote:

> Not every program using the json output will be in D (especially IDEs).

That's a good point. I don't think it hurts to have both. It's still a lot less code/text than the current format.

-- 
/Jacob Carlborg
January 26, 2013

On 23.01.2013 06:42, Andrei Alexandrescu wrote:
> On 1/22/13 3:36 PM, Walter Bright wrote:
>> On 1/22/2013 11:46 AM, Andrei Alexandrescu wrote:
>>> On 1/22/13 2:48 AM, Walter Bright wrote:
>>>> 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.
>>>
>>> Verbose should probably be it.
>>
>> Rationale?
>
> You can always filter out the verboseness with a simple program, but you
> can't add missing information.
>
> If the efficiency of generating json ever comes up, _then_ it's worth
> looking into an option that produces less verbose output directly. For
> now be verbose and let downstream tools filter it out.
>
>
> Andrei
>

I updated dmd from github and had a look at the current json output: it's horrible. Below is a random example of a simple function.

- the function parameters are listed three times with different type information

- "originalType" seems to be always shown, even though it probably was meant to if it is different from "type"

- if the parameter identifiers are listed separately anyway, they should not be part of the type while the types do not have to be repeated n the actual parameter list

- package and module are specified inconsistently, sometimes as an array of strings, sometimes in dot-notation, sometimes not at all.

- types are sometimes shown expanded, sometimes not (e.g. "string")

- template instantiations from imported source files are listed

- functions and template instantiations that are only used at compile time are listed

- I appreciate that some missing information has been added, like imports and storage class

- renamed imports don't show the original module name

- functions implemented through template mixins are not listed

- surprisingly the average output has only become about 10 times larger for a medium sized project like Visual D (73 MB instead of 8 MB). Having only std.json available for reading it, I suspect it will definitely have an impact on IDE performance, though.

I understand that most of these issues are QOI issues but it also seems that there is also a shift in the target usage of the JSON output. It was a means for source code browsing with output similar to generated di files, while it is now showing everything written into object files similar to debug info. Some of this can easily be filtered out (e.g. "template instance") but not all (e.g. functions from other modules only used in CTFE).

So I think that we should remove excessive bloat (e.g. always specify package and module lists in dot notation), make output more consistent and avoid listing the same type again and again. If a type is specified by its mangled name in declarations, add it to a dictionary at the end of the json file in its full verbosity. (I agree core.demangle does not help you if you want to do anything more than just getting the pretty type string). Please be aware that you will have to document the JSON type format in addition to the existing name mangling, though.

Rainer

--------
JSON output for
void setAttribute(Element elem, string attr, string val);

dmd 2.061:
{
"name" : "setAttribute",
"kind" : "function",
"protection" : "public",
"type" : "void(Element elem, string attr, string val)",
"line" : 37}
,


dmd 2.062alpha:
   {
    "name" : "setAttribute",
    "kind" : "function",
    "loc" : {
     "line" : 37
    },
    "module" : {
     "name" : "xmlwrap",
     "kind" : "module",
     "package" : [
      "visuald"
     ],
     "prettyName" : "visuald.xmlwrap"
    },
    "type" : {
     "kind" : "function",
     "pretty" : "void(Element elem, string attr, string val)",
     "returnType" : {
      "kind" : "void",
      "pretty" : "void"
     },
     "parameters" : [
      {
       "name" : "elem",
       "type" : {
        "kind" : "class",
        "pretty" : "std.xml.Element"
       }
      },
      {
       "name" : "attr",
       "type" : {
        "kind" : "darray",
        "pretty" : "string",
        "elementType" : {
         "kind" : "char",
         "pretty" : "immutable(char)",
         "modifiers" : " immutable"
        }
       }
      },
      {
       "name" : "val",
       "type" : {
        "kind" : "darray",
        "pretty" : "string",
        "elementType" : {
         "kind" : "char",
         "pretty" : "immutable(char)",
         "modifiers" : " immutable"
        }
       }
      }
     ]
    },
    "originalType" : {
     "kind" : "function",
     "pretty" : "void(Element elem, string attr, string val)",
     "returnType" : {
      "kind" : "void",
      "pretty" : "void"
     },
     "parameters" : [
      {
       "name" : "elem",
       "type" : {
        "kind" : "identifier",
        "pretty" : "Element",
        "idents" : [],
        "rawIdentifier" : "Element",
        "identifier" : "Element"
       }
      },
      {
       "name" : "attr",
       "type" : {
        "kind" : "identifier",
        "pretty" : "string",
        "idents" : [],
        "rawIdentifier" : "string",
        "identifier" : "string"
       }
      },
      {
       "name" : "val",
       "type" : {
        "kind" : "identifier",
        "pretty" : "string",
        "idents" : [],
        "rawIdentifier" : "string",
        "identifier" : "string"
       }
      }
     ]
    },
    "parameters" : [
     {
      "name" : "elem",
      "kind" : "variable",
      "loc" : {
       "line" : 37
      },
      "module" : {
       "name" : "xmlwrap",
       "kind" : "module",
       "package" : [
        "visuald"
       ],
       "prettyName" : "visuald.xmlwrap"
      },
      "type" : {
       "kind" : "class",
       "pretty" : "std.xml.Element"
      }
     },
     {
      "name" : "attr",
      "kind" : "variable",
      "loc" : {
       "line" : 37
      },
      "module" : {
       "name" : "xmlwrap",
       "kind" : "module",
       "package" : [
        "visuald"
       ],
       "prettyName" : "visuald.xmlwrap"
      },
      "type" : {
       "kind" : "darray",
       "pretty" : "string",
       "elementType" : {
        "kind" : "char",
        "pretty" : "immutable(char)",
        "modifiers" : " immutable"
       }
      }
     },
     {
      "name" : "val",
      "kind" : "variable",
      "loc" : {
       "line" : 37
      },
      "module" : {
       "name" : "xmlwrap",
       "kind" : "module",
       "package" : [
        "visuald"
       ],
       "prettyName" : "visuald.xmlwrap"
      },
      "type" : {
       "kind" : "darray",
       "pretty" : "string",
       "elementType" : {
        "kind" : "char",
        "pretty" : "immutable(char)",
        "modifiers" : " immutable"
       }
      }
     }
    ],
    "endloc" : {
     "line" : 40
    }
   },
January 26, 2013
On 1/26/2013 2:25 AM, Rainer Schuetze wrote:
> I updated dmd from github and had a look at the current json output: it's
> horrible. Below is a random example of a simple function.

Yeah, it's pretty bad.

1 2 3
Next ›   Last »