nitlang / nit

Nit language
http://nitlanguage.org
Apache License 2.0
242 stars 67 forks source link

Property groups #1413

Open privat opened 9 years ago

privat commented 9 years ago

In a class, people like to groups properties by concern. It is a standard way that two related properties are defined close together. Maybe Nit should provide an (optional) way to group them more formally. I do not thing that these kind of group of properties should have any semantic effect on the language but be pure documentation/storage concepts but available in the model for documentation and other software-engineering tools.

Some language, like Eiffel and Smalltalk, offer such an abstraction (respectively called feature group and method categories).

Note that I dot not have any proposal, neighter syntactically neither abstractly in the model, this issue is purely a topic of discussion.

ping @Morriar because it is something that should interest him.

Morriar commented 9 years ago

I totally agree on that. Even more since @ablondin is using them in its code.

I also agree that they should be available in the model to simplify the usage by client tools.

Morriar commented 9 years ago

My main concern is what happens with groups with refinement.

privat commented 9 years ago

For the model side, I propose that property groups are reified as properties, thus a group of properties

As you see, this is also a composite so groups of properties can be nested.

The syntactic issue is still unclear but on can try to map with how properties are defined: a keyword, a name and possible doc before it

class Foo
   # bla bla
   group bar

   fun toto do end

   # bla bla
   group baz

   fun tata do end
end
Morriar commented 9 years ago

I like it but there will be confusion with the groups as in Project/Group/Module

privat commented 9 years ago

Yeah group is a bad name and should be renamed.

By the way, maybe group of Project/Group/Module should also be renamed.

But i have no better idea...

There are two hard things in computer science: cache invalidation, naming things, and off-by-one errors

egagnon commented 9 years ago

Why add complexity to the base language, if it serves no semantic purpose? Can't the same be accomplished through some comment tag or something?