question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[suggestion] anonymous array declaration, relax object syntax (JS/Json syntax)

See original GitHub issue

Currently EE can evaluate anonymous object declarations:

x = new {a = 10, b = 20, c = 30}

property = value is enforced in method InitSimpleObjet (we should rename that to InitSimpleObject). First part of this suggestion is to relax this syntax and allow customization (preferably in the way customization of new works now) such as:

x = new {a: 10, b: 20, c: 30}

second part of this suggestion proposes support of JS-like anonymous array declaration (respecting c# new initialization pattern), which would internally map to List<object>:

x = new [10, 20, 30] // x[2] = 30

@codingseb do you think this would be possible to implement and of use?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
lofczcommented, May 26, 2021

Great news @codingseb thanks for all the effort you are putting into this!

1reaction
codingsebcommented, May 25, 2021

I already published an alpha version for v.1.5 from branch MakeScriptEvaluationMoreFlexible (See on nuget) to test some early features. We can test it here It already contains some cool script customization stuff and support Json syntax.

evaluator.OptionsSyntaxRules.IsNewKeywordForAnonymousExpandoObjectOptional = true;
evaluator.OptionsSyntaxRules.InitializerPropertyValueSeparators = new[] { "=", ":" };
evaluator.OptionsSyntaxRules.InitializerAllowStringForProperties = true;
evaluator.OptionsSyntaxRules.AllowSimplifiedCollectionSyntax = true;

// And we can also use (To do a List<object> in place of a object[]): 
evaluator.OptionsSyntaxRules.SimplifiedCollectionMode = SimplifiedCollectionMode.List;

Take note that it introduce some breaking changes with previous versions and some others breaking changes can still happend until the official 1.5.0.0 release For now there is no documentation for new features

Read more comments on GitHub >

github_iconTop Results From Across the Web

Anonymous Array in Java
An array in Java without any name is known as an anonymous array. ... Syntax: new <data type>[]{<list of values with comma separator>};....
Read more >
JSON Quick Syntax Reference
In Chapter 5 , you explore JSON arrays and their syntax and learn how to create arrays of data for JSON Object s...
Read more >
Declaring and using a array of anonymous objects in C# - ...
This created a anonymous object with two properties, one being integer and another string. All good here, but how should I declare a...
Read more >
More on MicroXML
Perhaps it would be easier to relax the rules on namespaces (possibly via some kind of declaration within the embedding HTML5) - but...
Read more >
@teambit/legacy-bit-id | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found