save() feature for iota

2022-11-02 Thread Salih Dincer via Digitalmars-d-learn
Hi All, Isn't there a save feature for `iota()`? ```d import std.stdio; import std.range; void main() { foreach(num; iota!char('a', 'f').chunks(3)/* "onetwosixfour".chunks(3)//*/ ) { //auto n = num.save(); num.writeln(": ", num.walkLength); }

Re: What's the correct way of creating an instance of class in D?

2022-11-02 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 3 November 2022 at 06:02:13 UTC, Mike Parker wrote: are in C++. D enforces the distinction that C++ ...that C++ programmers often follow by convention.

Re: What's the correct way of creating an instance of class in D?

2022-11-02 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 3 November 2022 at 05:41:06 UTC, Siarhei Siamashka wrote: Thanks for the link and also thanks for confirming that you have no clue what's going on. I think that what actually That's not necessary. He does know what's going on and pointed you to the correct place. The second para

Re: What's the correct way of creating an instance of class in D?

2022-11-02 Thread Siarhei Siamashka via Digitalmars-d-learn
On Thursday, 3 November 2022 at 05:10:06 UTC, matheus wrote: https://dlang.org/spec/class.html Thanks for the link and also thanks for confirming that you have no clue what's going on. I think that what actually happens is that the D code ```D A a2; a2.foo(); ``` is roughly equivalent

Re: What's the correct way of creating an instance of class in D?

2022-11-02 Thread matheus via Digitalmars-d-learn
On Thursday, 3 November 2022 at 04:41:14 UTC, Siarhei Siamashka wrote: ... https://dlang.org/spec/class.html Matheus.

What's the correct way of creating an instance of class in D?

2022-11-02 Thread Siarhei Siamashka via Digitalmars-d-learn
C++ code: ```C++ #include class A { public: void foo() { std::cout << "foo" << std::endl; } }; int main() { auto a1 = new A; a1->foo(); // prints "foo" A a2; a2.foo(); // prints "foo" delete a1; } ``` D code: ```D @safe: import std.stdio; class A { void foo() { writeln("foo"); } }

return attribute with latest DMD - dmd-nightly -unittest -dip1000

2022-11-02 Thread apz28 via Digitalmars-d-learn
why foo2 is not inferred as scope which is shorter scope then foo1? import std.stdio; @safe: class Obj {@safe: override string toString() { return "obj"; } } struct Foo1 {@safe: this(Obj obj) { this._obj = obj; } ~this() { _obj = null; } // do something with

Re: Make IN Dlang

2022-11-02 Thread Christian Köstlin via Digitalmars-d-learn
On 02.11.22 17:24, Kagamin wrote: Another idea is to separate the script and interpreter then compile them together. ``` --- interp.d --- import script; import ...more stuff ...boilerplate code int main() {   interpret(script.All);   return 0; } --- script.d --- #! ? module script; import min

Re: Make IN Dlang

2022-11-02 Thread Christian Köstlin via Digitalmars-d-learn
On 02.11.22 20:16, H. S. Teoh wrote: On Wed, Nov 02, 2022 at 03:08:36PM +, JN via Digitalmars-d-learn wrote: On Tuesday, 1 November 2022 at 23:40:22 UTC, Christian Köstlin wrote: sh("touch %s".format(t.name)); One of the problems of many Make-like tools is that they offe

Re: Make IN Dlang

2022-11-02 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Nov 02, 2022 at 03:08:36PM +, JN via Digitalmars-d-learn wrote: > On Tuesday, 1 November 2022 at 23:40:22 UTC, Christian Köstlin wrote: > > sh("touch %s".format(t.name)); > > One of the problems of many Make-like tools is that they offer lots of > freedom, especially w

Re: Make IN Dlang

2022-11-02 Thread Kagamin via Digitalmars-d-learn
Another idea is to separate the script and interpreter then compile them together. ``` --- interp.d --- import script; import ...more stuff ...boilerplate code int main() { interpret(script.All); return 0; } --- script.d --- #! ? module script; import mind; auto All=Task(...); ...more decla

Re: Make IN Dlang

2022-11-02 Thread Kagamin via Digitalmars-d-learn
But embedded sdl is likely to be dwarfed by the actual code anyway.

Re: Make IN Dlang

2022-11-02 Thread Kagamin via Digitalmars-d-learn
On Tuesday, 1 November 2022 at 23:40:22 UTC, Christian Köstlin wrote: I am still trying to find answers to the following questions: 1. Is it somehow possible to get rid of the dub single file scheme, and e.g. interpret a full dlang script at runtime? If there was an interpreter like ``` #!

Re: Make IN Dlang

2022-11-02 Thread JN via Digitalmars-d-learn
On Tuesday, 1 November 2022 at 23:40:22 UTC, Christian Köstlin wrote: sh("touch %s".format(t.name)); One of the problems of many Make-like tools is that they offer lots of freedom, especially when allowing you to launch arbitrary shell commands. But this also comes with drawb

Re: Make IN Dlang

2022-11-02 Thread Christian Köstlin via Digitalmars-d-learn
On 02.11.22 04:07, rikki cattermole wrote: Something to consider: dub can be used as a library. You can add your own logic in main to allow using your build specification to generate a dub file (either in memory or in file system). Nice ... I will perhaps give that a try! Kind regards, Chris

Re: Make IN Dlang

2022-11-02 Thread Christian Köstlin via Digitalmars-d-learn
On 02.11.22 03:25, Tejas wrote: On Tuesday, 1 November 2022 at 23:40:22 UTC, Christian Köstlin wrote: Dear dlang-folk, one of the tools I always return to is rake (https://ruby.github.io/rake/). For those that do not know it, its a little like make in the sense that you describe your build a

Re: Make IN Dlang

2022-11-02 Thread Christian Köstlin via Digitalmars-d-learn
On 02.11.22 00:51, Adam D Ruppe wrote: I don't have specific answers to your questions but your goal sounds similar to Atila's reggae project so it might be good for you to take a look at: https://code.dlang.org/packages/reggae Hi Adam, thanks for the pointer. I forgot about reggae ;-) From

Re: A strange DMD error

2022-11-02 Thread Keivan Shah via Digitalmars-d-learn
On Tuesday, 1 November 2022 at 17:05:03 UTC, ryuukk_ wrote: This reminds me of an issue i reported last year... https://issues.dlang.org/show_bug.cgi?id=22583 This seems to be very similar to the bug I am facing, mostly the same underlying issue. Should we somehow link the 2 issues and escal

Re: A strange DMD error

2022-11-02 Thread Keivan Shah via Digitalmars-d-learn
On Tuesday, 1 November 2022 at 16:39:57 UTC, Steven Schveighoffer wrote: 100% this is a bug in DMD. It should be filed. I ran some more tests, removing almost any of the parameters or changing their types seems to avoid the problem. I also added a parameter name for the second parameter, and