Re: Error: template instance does not match template declaration

2021-11-17 Thread Vitalii via Digitalmars-d-learn
On Wednesday, 17 November 2021 at 18:00:59 UTC, Steven Schveighoffer wrote: On 11/17/21 7:55 AM, Vitalii wrote: [...] Template parameters are of 3 types: 1. A type parameter. This has a single symbol name, and represents a type *provided by the caller*. [...] Steve, thank you very much

Re: Incomplete words read from file

2021-11-17 Thread pascal111 via Digitalmars-d-learn
On Thursday, 18 November 2021 at 01:28:47 UTC, jfondren wrote: On Thursday, 18 November 2021 at 01:21:00 UTC, pascal111 wrote: I fixed the code like this and it worked without breaking words, but this time it shows single lines as if the normal context is a poem. Can we fix this or the

Re: Incomplete words read from file

2021-11-17 Thread jfondren via Digitalmars-d-learn
On Thursday, 18 November 2021 at 01:21:00 UTC, pascal111 wrote: I fixed the code like this and it worked without breaking words, but this time it shows single lines as if the normal context is a poem. Can we fix this or the terminal will force us and make wrapping for lines?

Re: Incomplete words read from file

2021-11-17 Thread pascal111 via Digitalmars-d-learn
On Thursday, 18 November 2021 at 00:42:49 UTC, Ali Çehreli wrote: On 11/17/21 3:46 PM, pascal111 wrote: > I made small program that shows the content of textual files, and it > succeeded to show non-English (Ascii code) language, but in many lines > some words are not complete and their rests

Re: Simple text editor program

2021-11-17 Thread zjh via Digitalmars-d-learn
On Wednesday, 17 November 2021 at 03:21:34 UTC, Ali Çehreli wrote: On 11/16/21 6:10 PM, pascal111 I think 'med' is by Walter Bright; he uses that editor daily. Ali Med is too simple,just for learn. Actually, it's best to program with `VIM`,kinds of plugin. I've been saying that D we should

Re: Incomplete words read from file

2021-11-17 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Nov 18, 2021 at 12:39:12AM +, jfondren via Digitalmars-d-learn wrote: [...] > If what you're wanting to do is to *reshape* text so that it prints > with proper word-breaks across lines according to the current size of > the terminal, then you've got to do this work yourself. [...]

Re: Incomplete words read from file

2021-11-17 Thread Ali Çehreli via Digitalmars-d-learn
On 11/17/21 3:46 PM, pascal111 wrote: > I made small program that shows the content of textual files, and it > succeeded to show non-English (Ascii code) language, but in many lines > some words are not complete and their rests are in next lines, how can > fix it? D assumes UTF-8 encoding by

Re: Incomplete words read from file

2021-11-17 Thread jfondren via Digitalmars-d-learn
On Wednesday, 17 November 2021 at 23:46:15 UTC, pascal111 wrote: I made small program that shows the content of textual files, and it succeeded to show non-English (Ascii code) language, but in many lines some words are not complete and their rests are in next lines, how can fix it? there's

Incomplete words read from file

2021-11-17 Thread pascal111 via Digitalmars-d-learn
I made small program that shows the content of textual files, and it succeeded to show non-English (Ascii code) language, but in many lines some words are not complete and their rests are in next lines, how can fix it? "https://i.postimg.cc/rpP7dQYH/Screenshot-from-2021-11-18-01-40-43.png;

Re: Simple text editor program

2021-11-17 Thread bachmeier via Digitalmars-d-learn
On Wednesday, 17 November 2021 at 20:49:22 UTC, Dr Machine Code wrote: On Wednesday, 17 November 2021 at 03:21:34 UTC, Ali Çehreli wrote: On 11/16/21 6:10 PM, pascal111 wrote: Is there a so simple text editor written in D as an example for learners. I hope the editor whose code is written in D

Re: Simple text editor program

2021-11-17 Thread bachmeier via Digitalmars-d-learn
On Wednesday, 17 November 2021 at 21:37:01 UTC, Ali Çehreli wrote: On 11/17/21 12:49 PM, Dr Machine Code wrote: >> I think 'med' is by Walter Bright; he uses that editor daily. >> >> Ali > > It's a emacs' variant written in D? Yes. The dub page explains that the original author is Dave G.

Re: Simple text editor program

2021-11-17 Thread Ali Çehreli via Digitalmars-d-learn
On 11/17/21 12:49 PM, Dr Machine Code wrote: >> I think 'med' is by Walter Bright; he uses that editor daily. >> >> Ali > > It's a emacs' variant written in D? Yes. The dub page explains that the original author is Dave G. Conroy. med is written by Walter and is his favorite editor. (I should

Re: Simple text editor program

2021-11-17 Thread Dr Machine Code via Digitalmars-d-learn
On Wednesday, 17 November 2021 at 03:21:34 UTC, Ali Çehreli wrote: On 11/16/21 6:10 PM, pascal111 wrote: Is there a so simple text editor written in D as an example for learners. I hope the editor whose code is written in D is available with someone. I am not familiar with any of them but

Re: Simple text editor program

2021-11-17 Thread Adam D Ruppe via Digitalmars-d-learn
On Wednesday, 17 November 2021 at 02:10:07 UTC, pascal111 wrote: Is there a so simple text editor written in D as an example for learners. I hope the editor whose code is written in D is available with someone. Probably not what you really want but this old post has a cute sample program

Re: Error: template instance does not match template declaration

2021-11-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/17/21 7:55 AM, Vitalii wrote: Thank you for response, Tejas! What I intended to do was make a class with only two states ("Inspect" - do some analysis, "Execute" - do some stuff). That's why I tried to use template specialization. Template parameters are of 3 types: 1. A type

Re: Are templated functions always re-constructed?

2021-11-17 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Nov 17, 2021 at 11:12:22AM +, rempas via Digitalmars-d-learn wrote: > On Tuesday, 16 November 2021 at 21:30:08 UTC, H. S. Teoh wrote: > > > > Short answer: a template called with the same CT arguments will only > > be instantiated once, and reused thereafter. > > > > Long answer: the

Re: mixins

2021-11-17 Thread Paul Backus via Digitalmars-d-learn
On Wednesday, 17 November 2021 at 14:51:58 UTC, Abby wrote: Hello I would like to create validation mixin or mixin template which would return on error. Something like this: ``` mixin template Validate(a, b) { if(a > b) { writeln("invalid input"); return false; } }

Re: mixins

2021-11-17 Thread Tejas via Digitalmars-d-learn
On Wednesday, 17 November 2021 at 15:12:50 UTC, Tejas wrote: On Wednesday, 17 November 2021 at 14:51:58 UTC, Abby wrote: Hello I would like to create validation mixin or mixin template which would return on error. Something like this: ``` mixin template Validate(a, b) { if(a > b) {

Re: mixins

2021-11-17 Thread Tejas via Digitalmars-d-learn
On Wednesday, 17 November 2021 at 14:51:58 UTC, Abby wrote: Hello I would like to create validation mixin or mixin template which would return on error. Something like this: ``` mixin template Validate(a, b) { if(a > b) { writeln("invalid input"); return false; } }

mixins

2021-11-17 Thread Abby via Digitalmars-d-learn
Hello I would like to create validation mixin or mixin template which would return on error. Something like this: ``` mixin template Validate(a, b) { if(a > b) { writeln("invalid input"); return false; } } bool test(a,b) { mixin Validate!(a,b); on

[SOLVED] Re: Using in one class a constant defined in another class

2021-11-17 Thread chopchop via Digitalmars-d-learn
Thanks guys, it is very clear now.

Re: Error: template instance does not match template declaration

2021-11-17 Thread Tejas via Digitalmars-d-learn
On Wednesday, 17 November 2021 at 12:55:15 UTC, Vitalii wrote: Thank you for response, Tejas! What I intended to do was make a class with only two states ("Inspect" - do some analysis, "Execute" - do some stuff). That's why I tried to use template specialization. The following code compiles

Re: French and Greek strings

2021-11-17 Thread Kagamin via Digitalmars-d-learn
You can use the string type to hold non-ascii characters. Just a substring of another string.

Re: Error: template instance does not match template declaration

2021-11-17 Thread Vitalii via Digitalmars-d-learn
Thank you for response, Tejas! What I intended to do was make a class with only two states ("Inspect" - do some analysis, "Execute" - do some stuff). That's why I tried to use template specialization. The following code compiles successfully, but return *"fun with unknown"* instead of *"fun

Re: Error: template instance does not match template declaration

2021-11-17 Thread Tejas via Digitalmars-d-learn
On Wednesday, 17 November 2021 at 12:19:05 UTC, Tejas wrote: On Wednesday, 17 November 2021 at 10:10:43 UTC, Vitalii wrote: Hello! I am getting the following error: ``` inst.d(8): Error: template instance `Worker!(Mode.Inspect)` does not match template declaration `Worker(mode : Mode) ```

Re: Error: template instance does not match template declaration

2021-11-17 Thread Tejas via Digitalmars-d-learn
On Wednesday, 17 November 2021 at 10:10:43 UTC, Vitalii wrote: Hello! I am getting the following error: ``` inst.d(8): Error: template instance `Worker!(Mode.Inspect)` does not match template declaration `Worker(mode : Mode) ``` when compile next code: ``` enum Mode { Inspect, Execute }

Re: Are templated functions always re-constructed?

2021-11-17 Thread rempas via Digitalmars-d-learn
On Tuesday, 16 November 2021 at 21:30:08 UTC, H. S. Teoh wrote: Short answer: a template called with the same CT arguments will only be instantiated once, and reused thereafter. Long answer: the above applies per compilation. If you compile your sources separately, there may be multiple

Re: Are templated functions always re-constructed?

2021-11-17 Thread rempas via Digitalmars-d-learn
On Wednesday, 17 November 2021 at 02:50:43 UTC, Mike Parker wrote: You might find this useful: https://dlang.org/blog/2020/07/31/the-abcs-of-templates-in-d/ I do! Thanks a lot!

Error: template instance does not match template declaration

2021-11-17 Thread Vitalii via Digitalmars-d-learn
Hello! I am getting the following error: ``` inst.d(8): Error: template instance `Worker!(Mode.Inspect)` does not match template declaration `Worker(mode : Mode) ``` when compile next code: ``` enum Mode { Inspect, Execute } class Worker(mode : Mode) { this() {} } void main() {