rascal icon indicating copy to clipboard operation
rascal copied to clipboard

Writing ADT not overwritten default values

Open linuswagner opened this issue 1 year ago • 1 comments

I like to create metaData for my experiments. For that, I define an ADT and write it to json. Example:

data MetaData = metaData(
    datetime begin = now(),
    datetime end = now(),
    str usedModel = "",
    str commitIdMapperExperiments = getHeadId(|file:///home/linus/Documents/mapper-experiments|)
);

and then something like

md = metaData();
writeJSON(|some_path|, md, dateTimeAsInt=true, indent=4);

For some reason, the json file then only contains the string metaData. Only when I explicitly set the keyword attributes of the ADT, e.g.

md.begin = now();

the set attributes become part of the json.

I would expect that writing an ADT to a (json) file also includes the default values of the ADT, because (besides fitting my use-case), it cannot be guaranteed that default values remain unchanged between versions of Rascal. Since there is no version information in the file, this can lead to a loss of information.

linuswagner avatar Jan 14 '24 10:01 linuswagner

Seems like the attributes don't appear in the argument in the Java code to begin with, so the problem might be how ADTs are handed over to Java

linuswagner avatar Jan 15 '24 16:01 linuswagner