Giter VIP home page Giter VIP logo

Comments (6)

ruby0x1 avatar ruby0x1 commented on September 22, 2024 2

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.

ruby0x1 avatar ruby0x1 commented on September 22, 2024 1

The docs are here just in case, I think a group already behaves like you want?

from wren.

mwasplund avatar mwasplund commented on September 22, 2024 1

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.

ruby0x1 avatar ruby0x1 commented on September 22, 2024 1

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.

PureFox48 avatar PureFox48 commented on September 22, 2024 1

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.

mwasplund avatar mwasplund commented on September 22, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.