Comments (6)
Small note worth mentioning about the attributes is they also stack. See below, they come out as a list for before and after as well.
#before = ext1
#before = ext2
#isEnabled = false
#after = ext3
#whatever
class Example {}
from wren.
The docs are here just in case, I think a group already behaves like you want?
from wren.
Yes, you could fudge a group to pretend to be a list or map, however I interpreted them as a logical grouping of keys. In my case I was actually thinking of using a single group to provide a collection of properties for a class with some of them being lists themselves.
#extension(before = ["Ext1", "Ext2"], isEnabled = false, after = [ "Ext3" ]
class MyClass {
}
If groups are meant to be maps/lists, why not just use the existing syntax?
#extension = { "before": ["Ext1", "Ext2"], "isEnabled": false, "after": [ "Ext3" ] }
class MyClass {
}
from wren.
It's a simplified form of an ECMA standard.
When using a tool the way it's designed it's not really fudging anything. The tool provides a way to store multiple values in the same container, which sounded like what you're after.
As with most things in wren there's a trade off with simplicity and the minimal nature of the language. The attributes provide a wide range of expressiveness under a small simple set of rules which align with the goals
from wren.
Have you considered using a static indexer rather than an attribute?
class MyClass {
static [key] {
if (!__props) __props = {"before": ["Ext1", "Ext2"], "isEnabled": false, "after": ["Ext3"]}
return __props[key]
}
// blah
}
System.print(MyClass["before"]) //> [Ext1, Ext2]
System.print(MyClass["isEnabled"]) //> false
System.print(MyClass["after"]) //> [Ext3]
System.print(MyClass["whatever"]) //> null
from wren.
@ruby0x1, thanks for the answers. I was incorrectly understanding what the purpose of a group was. I think the method like signature threw me off. It felt odd that the language already had a built in concept of lists and maps and introduced a merged concept of groups for attributes. 🤷
@PureFox48, I think I am going to land on something similar to your proposal. A simple static getter should let me attach a list to a class object nicely.
from wren.
Related Issues (20)
- [RFC] Add routines for degrees/radians conversions HOT 21
- [RFC] Adding a `Tuple` with language support HOT 11
- [RFC] Adding `const` versions of `Object`s. HOT 9
- Class reflection for embedding HOT 3
- [RFC] `veery` lang transpiler to `wren` lang HOT 3
- [RFC] Object method message passing syntax HOT 28
- [RFC] Add `static Object.typeOf(_)` (and deprecate `Object.type` ?) HOT 9
- How can i stop wren script running? HOT 3
- Calling wren method handle from inside a bound foreign method body HOT 5
- Whitespace bugs? HOT 4
- Serialize (suspended) fibers or serialize the vm HOT 4
- wren_debug.c should use vm->config.writeFn instead of printf HOT 1
- Should we document this aspect of for loop control variable behavior?
- How do I pass a foreign object to a function call? HOT 3
- is Wren dead? HOT 2
- Where causes code to be called twice HOT 3
- How to return other foreign class obj from a foreign class ? HOT 7
- wrenCall -> foreign call causes memory corruption HOT 11
- Compound Assignments HOT 1
- System.print does not use overridden toString HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wren.