digitalmars.D - UDA for module declaration.
- IgorStepanov (67/67) Sep 16 2014 Why not subj?
- Orvid King (6/73) Sep 16 2014 UDA's for enum members do make sense, especially in the case of
- Timon Gehr (4/9) Sep 17 2014 As far as I am concerned, this does not need any justification, but
- Dicebot (4/18) Sep 17 2014 I agree. "Language consistency" sounds like good justification
- Max Samukha (4/18) Jun 18 2021 Really. Walter, please note that the lack of this feature makes
- Max Samukha (2/3) Jun 18 2021 turn
- jmh530 (12/16) Jun 18 2021 It looks like this PR was merged...
- Dominikus Dittes Scherkl (1/1) Jun 18 2021 Is it really necessary to re-animate some seven year old threads?
- Max Samukha (2/3) Jun 18 2021 Yes, my bad. Sorry for the noise.
- Nicholas Wilson (3/9) Jun 18 2021 The thread you're replying to is like 7 years old. Please try to
- Max Samukha (3/12) Jun 18 2021 I will, though I find the dogmatic prejudice against necroposting
- claptrap (7/20) Jun 18 2021 Are you sure you really mean that? I mean politely asking you not
- Max Samukha (2/8) Jun 20 2021
- Daniel Kozak via Digitalmars-d (4/13) Sep 17 2014 Month ago I need UDA for module declarations too, so I hack my own
- Johannes Pfau (11/27) Sep 17 2014 In GDC we mosty use UDAs instead of pragmas, so you can do
- ketmar via Digitalmars-d (4/5) Sep 17 2014 this can be very useful, so i'm sure that it will be called "useless"
Why not subj? D allows annotate with UDA the most of named symbols. There are three category of named symbols, which cannot be annotated: module declarations, function arguments and enum members. Enum members are trivial symbols and annotation possibility for them probably does not make sense. However, annotation unpossibility for module declaration and function arguments looks strange. Why all this talk? I've created pull request for dmd, which allows UDA for modules (https://github.com/D-Programming-Language/dmd/pull/3947) and Walter says that I should open topic in n.g. and justify the usefulness of this enhancement. I will give a few examples when UDA can be used for modules and arguments: First example: in ORM framework, like hibernate, I want to add posibility to put the module in correspondence to DB scheme: Sheme("STOCK") module Stock; Entity("WAYBILLS") class Waybill //STOCK.WAYBILLS { .... } Entity("ITEMS") class Item //STOCK.ITEMS { .... } *************************************************** The second example is a Web MVC framework BindModule("forum") module dlang.engine.controllers.forum; BindPath("/") class MainController : AbstractController!(MainController) { BindMethod("/newpost") View newPost(Request req, BindParam("tid") int threadID, BindParam("author") string author, BindParam("subj") string subject, BindParam("msg") string message) { /// return new TemplateView(model, "/dlang/templates/forum/newpost.tmpl"); } } *************************************************** The third example is a my runtime reflection implementation: I've created generator which walking down the scope symbol, and store runtime data, if symbol is annotated with a special UDA. For example, if class Annotated with reflect!all, generator will save information about all class members into special place. However, if local scope symbol is not annotated, information about its members will not saved: reflect!all class Foo { int a; class Bar { int b; } } In this example, information for Foo will be saved (that Foo contains "a" and class "Bar"), but information about Bar members will not be saved. Thus I want to be able to annotate module that the generator will keep information about its members. Destroy.
Sep 16 2014
On Wednesday, 17 September 2014 at 00:46:07 UTC, IgorStepanov wrote:Why not subj? D allows annotate with UDA the most of named symbols. There are three category of named symbols, which cannot be annotated: module declarations, function arguments and enum members. Enum members are trivial symbols and annotation possibility for them probably does not make sense. However, annotation unpossibility for module declaration and function arguments looks strange. Why all this talk? I've created pull request for dmd, which allows UDA for modules (https://github.com/D-Programming-Language/dmd/pull/3947) and Walter says that I should open topic in n.g. and justify the usefulness of this enhancement. I will give a few examples when UDA can be used for modules and arguments: First example: in ORM framework, like hibernate, I want to add posibility to put the module in correspondence to DB scheme: Sheme("STOCK") module Stock; Entity("WAYBILLS") class Waybill //STOCK.WAYBILLS { .... } Entity("ITEMS") class Item //STOCK.ITEMS { .... } *************************************************** The second example is a Web MVC framework BindModule("forum") module dlang.engine.controllers.forum; BindPath("/") class MainController : AbstractController!(MainController) { BindMethod("/newpost") View newPost(Request req, BindParam("tid") int threadID, BindParam("author") string author, BindParam("subj") string subject, BindParam("msg") string message) { /// return new TemplateView(model, "/dlang/templates/forum/newpost.tmpl"); } } *************************************************** The third example is a my runtime reflection implementation: I've created generator which walking down the scope symbol, and store runtime data, if symbol is annotated with a special UDA. For example, if class Annotated with reflect!all, generator will save information about all class members into special place. However, if local scope symbol is not annotated, information about its members will not saved: reflect!all class Foo { int a; class Bar { int b; } } In this example, information for Foo will be saved (that Foo contains "a" and class "Bar"), but information about Bar members will not be saved. Thus I want to be able to annotate module that the generator will keep information about its members. Destroy.UDA's for enum members do make sense, especially in the case of serialization, where you might want a member to be used in your code as one thing, but parsed as a different name, for instance, serializing code where the enum member would be a keyword in D.
Sep 16 2014
On 09/17/2014 03:43 AM, Orvid King wrote:Why all this talk? I've created pull request for dmd, which allows UDA for modules (https://github.com/D-Programming-Language/dmd/pull/3947) and Walter says that I should open topic in n.g. and justify the usefulness of this enhancement.As far as I am concerned, this does not need any justification, but leaving it out would. A module declaration is as much a declaration as any other declaration and declarations can be annotated with UDAs.
Sep 17 2014
On Wednesday, 17 September 2014 at 12:30:26 UTC, Timon Gehr wrote:On 09/17/2014 03:43 AM, Orvid King wrote:I agree. "Language consistency" sounds like good justification here on its own, the less special cases we have, the better it is for the learning curve.Why all this talk? I've created pull request for dmd, which allows UDA for modules (https://github.com/D-Programming-Language/dmd/pull/3947) and Walter says that I should open topic in n.g. and justify the usefulness of this enhancement.As far as I am concerned, this does not need any justification, but leaving it out would. A module declaration is as much a declaration as any other declaration and declarations can be annotated with UDAs.
Sep 17 2014
On Wednesday, 17 September 2014 at 12:30:26 UTC, Timon Gehr wrote:On 09/17/2014 03:43 AM, Orvid King wrote:Really. Walter, please note that the lack of this feature makes me turning my codebase into shit right now, not in some indeterminate future.Why all this talk? I've created pull request for dmd, which allows UDA for modules (https://github.com/D-Programming-Language/dmd/pull/3947) and Walter says that I should open topic in n.g. and justify the usefulness of this enhancement.As far as I am concerned, this does not need any justification, but leaving it out would. A module declaration is as much a declaration as any other declaration and declarations can be annotated with UDAs.
Jun 18 2021
On Friday, 18 June 2021 at 10:55:58 UTC, Max Samukha wrote:turningturn
Jun 18 2021
On Friday, 18 June 2021 at 10:55:58 UTC, Max Samukha wrote:[snip] Really. Walter, please note that the lack of this feature makes me turning my codebase into shit right now, not in some indeterminate future.It looks like this PR was merged... ```d UDA(42) module test; struct UDA { int a; } pragma(msg, __traits(getAttributes, test)); //prints "tuple(UDA(42))" void main() {} ```
Jun 18 2021
Is it really necessary to re-animate some seven year old threads?
Jun 18 2021
On Friday, 18 June 2021 at 11:21:34 UTC, jmh530 wrote:It looks like this PR was merged...Yes, my bad. Sorry for the noise.
Jun 18 2021
On Friday, 18 June 2021 at 10:55:58 UTC, Max Samukha wrote:On Wednesday, 17 September 2014 at 12:30:26 UTC, Timon Gehr wrote:The thread you're replying to is like 7 years old. Please try to avoid resurrecting very old threads.On 09/17/2014 03:43 AM, Orvid King wrote:Really. Walter, please note that the lack of this feature makes me turning my codebase into shit right now, not in some indeterminate future.
Jun 18 2021
On Friday, 18 June 2021 at 12:09:56 UTC, Nicholas Wilson wrote:On Friday, 18 June 2021 at 10:55:58 UTC, Max Samukha wrote:I will, though I find the dogmatic prejudice against necroposting abhorrent.On Wednesday, 17 September 2014 at 12:30:26 UTC, Timon Gehr wrote:The thread you're replying to is like 7 years old. Please try to avoid resurrecting very old threads.On 09/17/2014 03:43 AM, Orvid King wrote:Really. Walter, please note that the lack of this feature makes me turning my codebase into shit right now, not in some indeterminate future.
Jun 18 2021
On Friday, 18 June 2021 at 19:53:51 UTC, Max Samukha wrote:On Friday, 18 June 2021 at 12:09:56 UTC, Nicholas Wilson wrote:Are you sure you really mean that? I mean politely asking you not to resurrect old threads is "abhorrent" and not merely just a bit irritating? "Abhorrent" is usually reserved for stuff that will put you in jail for a good few years. Do you think we should lock Nicholas up for a while? Otherwise it was a nice turn of phrase. :)On Friday, 18 June 2021 at 10:55:58 UTC, Max Samukha wrote:I will, though I find the dogmatic prejudice against necroposting abhorrent.On Wednesday, 17 September 2014 at 12:30:26 UTC, Timon Gehr wrote:The thread you're replying to is like 7 years old. Please try to avoid resurrecting very old threads.On 09/17/2014 03:43 AM, Orvid King wrote:Really. Walter, please note that the lack of this feature makes me turning my codebase into shit right now, not in some indeterminate future.
Jun 18 2021
On Friday, 18 June 2021 at 21:05:58 UTC, claptrap wrote:Are you sure you really mean that? I mean politely asking you not to resurrect old threads is "abhorrent" and not merely just a bit irritating? "Abhorrent" is usually reserved for stuff that will put you in jail for a good few years. Do you think we should lock Nicholas up for a while?Nicholas is too valuable to be put in jail.Otherwise it was a nice turn of phrase. :)
Jun 20 2021
V Wed, 17 Sep 2014 00:46:04 +0000 IgorStepanov via Digitalmars-d <digitalmars-d puremagic.com> napsáno:Why not subj? D allows annotate with UDA the most of named symbols. There are three category of named symbols, which cannot be annotated: module declarations, function arguments and enum members. Enum members are trivial symbols and annotation possibility for them probably does not make sense. However, annotation unpossibility for module declaration and function arguments looks strange.Month ago I need UDA for module declarations too, so I hack my own version of DMD. It would be fine if this would be in upstream.
Sep 17 2014
Am Wed, 17 Sep 2014 00:46:04 +0000 schrieb "IgorStepanov" <wazar mail.ru>:Why not subj? D allows annotate with UDA the most of named symbols. There are three category of named symbols, which cannot be annotated: module declarations, function arguments and enum members. Enum members are trivial symbols and annotation possibility for them probably does not make sense. However, annotation unpossibility for module declaration and function arguments looks strange. Why all this talk? I've created pull request for dmd, which allows UDA for modules (https://github.com/D-Programming-Language/dmd/pull/3947) and Walter says that I should open topic in n.g. and justify the usefulness of this enhancement.In GDC we mosty use UDAs instead of pragmas, so you can do attribute("forceinline") void foo() {}... or forceinline void foo() {}... Obviously there are pragmas which apply to a module (e.g LDC's nomoduleinfo pragma) which we can't represent as an UDA right now. So nomoduleinfo module a; is another possible usecase.
Sep 17 2014
On Wed, 17 Sep 2014 00:46:04 +0000 IgorStepanov via Digitalmars-d <digitalmars-d puremagic.com> wrote:Why not subj?this can be very useful, so i'm sure that it will be called "useless" and "broken".
Sep 17 2014