Skip to content
This repository has been archived by the owner on Sep 7, 2023. It is now read-only.

Print result of evaluation in Ergo Syntax #337

Closed
jeromesimeon opened this issue Jul 24, 2018 · 3 comments
Closed

Print result of evaluation in Ergo Syntax #337

jeromesimeon opened this issue Jul 24, 2018 · 3 comments

Comments

@jeromesimeon
Copy link
Member

When evaluating Ergo, it would be nice to have the option to print the result in Ergo syntax. Currently it uses JSON which does provide the information but can be a bit confusing since this is more like a serialization syntax.

This can be best illustrated with the REPL.

For:

$ ./bin/ergotop ./examples/helloworld/model.cto ./examples/helloworld/logic.ergo 
Welcome to ERGOTOP version 0.1.3
ergo$ import org.accordproject.helloworld.*
ergo$ set contract HelloWorld over TemplateModel{ name : "Tigger" }
ergo$ call helloworld(Request{ input : "Foorest" });
Response. {"type": ["org.accordproject.helloworld.Response"], "data": {"output": "Hello Tigger (Foorest)"}}

The response could be written as:

ergo$ call helloworld(Request{ input : "Foorest" });
Response. Response{ output : "Hello Tigger (Foorest)" }

or

ergo$ call helloworld(Request{ input : "Foorest" });
Response. ~org.accordproject.helloworld.Response{ output : "Hello Tigger (Foorest)" }

For:

ergo$ return 1;
Response. {"nat": 1.0}

The response could be written as:

ergo$ return 1;
Response. 1

For:

ergo$ define constant zenbear = "pooh"
ergo$ return Request{ input : zenbear };
Response. {"type": ["org.accordproject.helloworld.Request"], "data": {"input": "pooh"}}

The response could be written as:

ergo$ return Request{ input : zenbear };
Response. Request{ input: "pooh" }

For:

ergo$ return nil;
Response. null

The response could be written as:

ergo$ return nil;
Response. nil

(Or whichever syntax we use for an empty optional -- See discussion in #321)

@jeromesimeon
Copy link
Member Author

jeromesimeon commented Jul 24, 2018

Also for:

ergo$ return some(1.5 * 2.0);
Response. {"left": 3.0}

The response could be written as:

ergo$ return some(1.5 * 2.0);
Response. some(3.0)

@jeromesimeon
Copy link
Member Author

Similar issues will arise when #2 and #3 are resolved

@kach
Copy link
Contributor

kach commented Aug 3, 2018

#364

@kach kach closed this as completed Aug 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants