Re: RFC to: my need for 'static switch' and CT 'static variables'

2021-11-25 Thread Alexey via Digitalmars-d-learn
On Friday, 26 November 2021 at 00:41:34 UTC, Elronnd wrote: you are right. thanks

Re: RFC to: my need for 'static switch' and CT 'static variables'

2021-11-25 Thread Elronnd via Digitalmars-d-learn
static if (...) { } else static if (...) { } else { static assert(0); }

Re: RFC to: my need for 'static switch' and CT 'static variables'

2021-11-25 Thread Alexey via Digitalmars-d-learn
On Thursday, 25 November 2021 at 22:00:15 UTC, Alexey wrote: I would want an static 'switch here', I mean something like ```D static switch (v.mode) { default: static assert(false, "v.mode" is invalid) case "gs_w_d": // etc... } ```

RFC to: my need for 'static switch' and CT 'static variables'

2021-11-25 Thread Alexey via Digitalmars-d-learn
for example, I have the code (code in sample generates different types of Properties dependingly on struct's mode value): ```D struct PropSetting { string mode; string type; string var_name; string title_name; string default_value; } mixin template mixin_install_multiple_prop

Re: What is pure used for?

2021-11-25 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 25 November 2021 at 07:26:48 UTC, sclytrack wrote: int * pureFunction() 1) the pointer needs to be the same. 2) the value that the pointer points to needs to be the same. I call this the "value of interest" with relation to pure. The pointer doesn't matter. 3) both the pointer and

Re: Attributes (lexical)

2021-11-25 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Thursday, 25 November 2021 at 12:16:50 UTC, rumbu wrote: I try to base my reasoning on specification, dmd is not always a good source of information, the lexer is polluted by old features or right now by the ImportC feature, trying to lex D an C in the same time. Alright. I haven't looked

Re: Attributes (lexical)

2021-11-25 Thread Dennis via Digitalmars-d-learn
On Thursday, 25 November 2021 at 12:09:55 UTC, Dennis wrote: This should also be fixed in the spec. Filed as: Issue 22543 - [spec] grammar blocks use unspecified notation: https://issues.dlang.org/show_bug.cgi?id=22543 Issue 22544 - [spec] C++ and Objective-C are not single tokens https://iss

Re: Attributes (lexical)

2021-11-25 Thread rumbu via Digitalmars-d-learn
On Thursday, 25 November 2021 at 11:25:49 UTC, Ola Fosheim Grøstad wrote: On Thursday, 25 November 2021 at 10:41:05 UTC, Rumbu wrote: I am not asking this questions out of thin air, I am trying to write a conforming lexer and this is one of the ambiguities. I think it is easier to just look at

Re: Attributes (lexical)

2021-11-25 Thread zjh via Digitalmars-d-learn
On Thursday, 25 November 2021 at 08:06:27 UTC, rumbu wrote: # //this works line I hate `#`.

Re: Attributes (lexical)

2021-11-25 Thread Dennis via Digitalmars-d-learn
On Thursday, 25 November 2021 at 10:41:05 UTC, Rumbu wrote: Well: ``` #line IntegerLiteral Filespec? EndOfLine ``` Having EndOfLine at the end means for me that there are no other EOLs between, otherwise this syntax should pass but it's not (DMD last): ```d #line 12 "source.d" ``` The lex

Re: Include .def definition file information for the linker into a .d source file

2021-11-25 Thread Imperatorn via Digitalmars-d-learn
On Thursday, 25 November 2021 at 09:47:50 UTC, Stanislav Blinov wrote: On Thursday, 25 November 2021 at 09:00:52 UTC, Imperatorn wrote: What most ppl do in that case is to just provide a script, for example build.cmd that just does what it needs. The user just clicks the script and it does eve

Re: Attributes (lexical)

2021-11-25 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Thursday, 25 November 2021 at 10:41:05 UTC, Rumbu wrote: I am not asking this questions out of thin air, I am trying to write a conforming lexer and this is one of the ambiguities. I think it is easier to just look at the lexer in the dmd source. The D language does not really have a proper

Re: Attributes (lexical)

2021-11-25 Thread Rumbu via Digitalmars-d-learn
On Thursday, 25 November 2021 at 10:10:25 UTC, Dennis wrote: On Thursday, 25 November 2021 at 08:06:27 UTC, rumbu wrote: Also, this works also for #line, even if the specification tells us that all tokens must be on the same line Where does it say that? Well: ``` #line IntegerLiteral Filesp

Re: Attributes (lexical)

2021-11-25 Thread Dennis via Digitalmars-d-learn
On Thursday, 25 November 2021 at 08:06:27 UTC, rumbu wrote: Also, this works also for #line, even if the specification tells us that all tokens must be on the same line Where does it say that?

Re: Include .def definition file information for the linker into a .d source file

2021-11-25 Thread Stanislav Blinov via Digitalmars-d-learn
On Thursday, 25 November 2021 at 09:00:52 UTC, Imperatorn wrote: What most ppl do in that case is to just provide a script, for example build.cmd that just does what it needs. The user just clicks the script and it does everything for them. "How can I make it so that I don't need an extra fil

Re: Attributes (lexical)

2021-11-25 Thread Elronnd via Digitalmars-d-learn
On Thursday, 25 November 2021 at 08:06:27 UTC, rumbu wrote: Is that ok or it's a lexer bug? @ (12) does exactly what I would expect. @nogc I always assumed was a single token, but the spec says otherwise. I suppose that makes sense. #line is dicier as it is not part of the grammar proper;

Re: Include .def definition file information for the linker into a .d source file

2021-11-25 Thread zjh via Digitalmars-d-learn
On Thursday, 25 November 2021 at 06:56:38 UTC, BoQsc wrote: In other words: as simple as possible to use. `dmd -i`,no need `one big file`.

Re: Include .def definition file information for the linker into a .d source file

2021-11-25 Thread Imperatorn via Digitalmars-d-learn
On Wednesday, 24 November 2021 at 17:06:21 UTC, BoQsc wrote: I'm not sure if I have sucessfully achieved something like this before or is it even possible right now, but there is a sample file that comes with DMD compiler: `D\dmd2\samples\d\winsamp.d` **The problem:** `winsamp.d` have to be co

Re: What is pure used for?

2021-11-25 Thread zjh via Digitalmars-d-learn
On Thursday, 25 November 2021 at 07:26:48 UTC, sclytrack wrote: My understanding is that pure is used for compiler optimization in loops and expressions. It leaves out multiple calls if it figures out it is not needed. [one link](https://klickverbot.at/blog/2012/05/purity-in-d/#indirections

Re: What is pure used for?

2021-11-25 Thread Imperatorn via Digitalmars-d-learn
On Thursday, 25 November 2021 at 07:26:48 UTC, sclytrack wrote: My understanding is that pure is used for compiler optimization in loops and expressions. It leaves out multiple calls if it figures out it is not needed. Is pure used for anything else? int * pureFunction() 1) the pointer need

Re: Attributes (lexical)

2021-11-25 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Thursday, 25 November 2021 at 08:06:27 UTC, rumbu wrote: Is that ok or it's a lexer bug? Yes. The lexer just eats whitespace and the parser accepts way too much.

Attributes (lexical)

2021-11-25 Thread rumbu via Digitalmars-d-learn
Just playing around with attributes. This is valid D code: ```d @ nogc: //yes, this is @nogc in fact, even some lines are between @ /* i can put some comments */ /** even some documentation */ // single line comments also (12) // yes, comments and newlines are allowed between attribute