Re: druntime homebrew: setup and compile a single project with its own stdlib
On Saturday, 28 October 2023 at 18:37:37 UTC, Dmitry Ponyatov wrote: I want to play with reimplementing some tiny set of standard D library, mostly for language learning, and need some advice - is it possible to use `dub` both for building custom druntime and test app? - or I must write some batch or Makefile and call `dmd` compiler directly onto every file? - what `dmd`/`dub` command line options forces it to drop system-wide druntime/phobos and use custom local .so / .a library in place of it? - is it possible to use `dub` both for building custom druntime and test app? Yes, my engine does that what `dmd`/`dub` command line options forces it to drop system-wide druntime/phobos and use custom local .so / .a library in place of it? If you have a module source file with the same name you want to replace, the build will prioritize your own version.
Re: Unable to use template functions to define variables of a class
On Saturday, 28 October 2023 at 12:38:42 UTC, Subhaditya Nath wrote: This works fine – I think it's because you're using a class. Try for example: ```d import std.range; import std.stdio; import std.algorithm.iteration; void main() { auto cls = new Class; cls.range1.each!writeln; } class Class { auto range1() { return iota(0, 100).filter!(x => x % 2).take(25); } } ``` The lambda function x => x % 2 is created within the class scope, which means it implicitly captures this. The filter function is a template that gets instantiated in a way that requires access to this, which is not available in the static context. The range1 member is declared like a field within the Class, but it's initialized in place, outside of a constructor or method. This sort of initialization doesn't have access to this because it's not happening within an instance context (like within a method where this is valid). So, then maybe you understand why it didn't work.
Unable to use template functions to define variables of a class
This works fine – ```d import std.stdio : writeln; import std.range : iota, take; import std.algorithm : filter, map, each; void main() { auto range1 = iota(0, 100) .filter!(x => x % 2) .take(50); range1.each!writeln; } ``` This also works fine – ```d void main() { auto cls = new Class; cls.range1.each!writeln; } class Class { auto range1 = iota(0, 100) .take(50); } ``` But this doesn't – ```d void main() { auto cls = new Class; cls.range1.each!writeln; } class Class { auto range1 = iota(0, 100) .filter!(x => x % 2) .take(50); } ``` Adding the `.filter!` messes things up. Same with `.map!` ```d void main() { auto cls = new Class; cls.range1.each!writeln; } class Class { auto range1 = iota(0, 100) .map!(x => x * 2) .take(50); } ``` My question is, why? I mean, am I just dumb or is this some kinda bug?
Re: dlang.org/spec/function.html#pure-functions example
On Monday, 16 October 2023 at 18:05:04 UTC, Paul wrote: On Thursday, 12 October 2023 at 21:20:44 UTC, Jonathan M Davis wrote: look like? Types can have static members. Basically what it comes down to is that outside of immutable data, pure functions only have access to their arguments and to what they can access via their arguments (be it by getting pointers from those arguments or calling other pure functions on them). - Jonathan M Davis Can I say in the general sense that when the word static is used it means that something is defined/declared at compile time? This link should describe all the uses of `static`: https://dlang.org/spec/attribute.html#static