Re: Any way to automatically convert structs on return?

2024-08-01 Thread user1234 via Digitalmars-d-learn
On Thursday, 1 August 2024 at 10:59:03 UTC, IchorDev wrote: On Thursday, 1 August 2024 at 09:55:08 UTC, user1234 wrote: The problem would be that sorting the candidates of an overload set would be more complicated. Also in certain cases it would be less obvious to get which one is selected.

Re: Any way to automatically convert structs on return?

2024-08-01 Thread user1234 via Digitalmars-d-learn
On Thursday, 1 August 2024 at 08:46:00 UTC, IchorDev wrote: [...] I’m pretty sure this is intentional to prevent ambiguity, but I can’t quite remember what the point of that is. The problem would be that sorting the candidates of an overload set would be more complicated. Also in certain

Re: Weird std.path API?

2024-07-08 Thread user1234 via Digitalmars-d-learn
On Monday, 8 July 2024 at 07:29:27 UTC, aberba wrote: On Sunday, 7 July 2024 at 15:35:36 UTC, Andrey Zherikov wrote: On Sunday, 7 July 2024 at 14:49:52 UTC, Anonymouse wrote: On Sunday, 7 July 2024 at 14:41:31 UTC, Andrey Zherikov wrote: ```d import std.path; // Error: no property

Re: Wrapper around a recursive data type

2024-07-08 Thread user1234 via Digitalmars-d-learn
On Monday, 8 July 2024 at 08:56:51 UTC, drug007 wrote: I need to generate some meta info of my data types. I do it this [...] How can I "break" this recursion or some other work around to fix it? Use `Node*[]` for the children type. That way the compiler knows the size of the (previously)

Re: Weird std.path API?

2024-07-07 Thread user1234 via Digitalmars-d-learn
On Sunday, 7 July 2024 at 15:35:36 UTC, Andrey Zherikov wrote: On Sunday, 7 July 2024 at 14:49:52 UTC, Anonymouse wrote: On Sunday, 7 July 2024 at 14:41:31 UTC, Andrey Zherikov wrote: ```d import std.path; // Error: no property `asNormaliedPath` for `dirName("/sandbox/onlineapp.d")` of type

Re: Debug with GDB on Windows

2024-05-25 Thread user1234 via Digitalmars-d-debugger
On Saturday, 18 May 2024 at 22:57:23 UTC, Aleksey Gorelov wrote: I am trying to debug on windows. A simple hello world app compiled with ``` "c:\D\ldc2-1.38.0-windows-x64\bin\ldc2.exe" -gdwarf -O0 app.d ``` has debug symbols. But the same app compiled with ``` dub build -b debug

Re: Why is Phobos `Flag` so overthought ?

2024-05-06 Thread user1234 via Digitalmars-d-learn
On Monday, 6 May 2024 at 18:06:53 UTC, Julian Fondren wrote: On Monday, 6 May 2024 at 17:55:49 UTC, user1234 wrote: I think this just works: ```d enum Flag : bool { no, yes } alias AllowVancancy = Flag; // example usage ``` ```d import std.stdio : writeln; enum Flag : bool { no,

Why is Phobos `Flag` so overthought ?

2024-05-06 Thread user1234 via Digitalmars-d-learn
I think this just works: ```d enum Flag : bool { no, yes } alias AllowVancancy = Flag; // example usage ``` Also this is completion friendly whereas Phobos version does not permit DCD completion as it's based on opDispatch. Compare to phobos version: ```d template Flag(string name)

Re: Deprecation: foreach: loop index implicitly converted from size_t to int

2024-05-03 Thread user1234 via Digitalmars-d-learn
On Friday, 3 May 2024 at 15:19:13 UTC, user1234 wrote: On Friday, 3 May 2024 at 14:59:57 UTC, BoQsc wrote: On Friday, 3 May 2024 at 13:18:02 UTC, user1234 wrote: [...] So how would you update this example, what is the right index type here to choose? ``` import std.stdio : writefln;

Re: Deprecation: foreach: loop index implicitly converted from size_t to int

2024-05-03 Thread user1234 via Digitalmars-d-learn
On Friday, 3 May 2024 at 14:59:57 UTC, BoQsc wrote: On Friday, 3 May 2024 at 13:18:02 UTC, user1234 wrote: On Friday, 3 May 2024 at 10:50:03 UTC, BoQsc wrote: [...] **You can specify the index type, just choose the right one.** For now there's a deprecation message but after some while

Re: Deprecation: foreach: loop index implicitly converted from size_t to int

2024-05-03 Thread user1234 via Digitalmars-d-learn
On Friday, 3 May 2024 at 10:50:03 UTC, BoQsc wrote: Why am I forced to visit this D Lang thread, why this deprecation warning still appears in my console window in the latest version of DMD. Does not make any sense from the developer's perspective to show this warning and pollute the already

Re: aliasing private

2024-05-01 Thread user1234 via Digitalmars-d-learn
On Wednesday, 1 May 2024 at 12:07:26 UTC, NotYouAgain wrote: I want to do a C like #define on private, but I can't ie. #define private fileprivate // --- module m; alias fileprivate = private; // grr! class myClass { fileprivate int n; } // --- You cant. That is simply not supported.

Re: How to add a character literal to a string without ~ operator?

2024-04-04 Thread user1234 via Digitalmars-d-learn
On Thursday, 4 April 2024 at 19:56:50 UTC, Ferhat Kurtulmuş wrote: On Thursday, 4 April 2024 at 18:14:54 UTC, BoQsc wrote: I'm looking for more readable standard function to add a **character** literal to a **string**. The `~` operator is clearly not great while reading a source code. I'm

Re: static functions?

2024-03-11 Thread user1234 via Digitalmars-d-learn
On Monday, 11 March 2024 at 16:51:48 UTC, Andy Valencia wrote: On Monday, 11 March 2024 at 16:25:13 UTC, Jonathan M Davis wrote: ... But what exactly static means varies based on the context. Thank you for the list! But none of those appear to apply to a function defined in the outermost

Re: New update fix

2024-03-02 Thread user1234 via Digitalmars-d-learn
On Saturday, 2 March 2024 at 08:41:40 UTC, Salih Dincer wrote: SLM, What exactly did this patch with the new update fix? Nothing, it looks like what happened is that the issue was wrongly referenced by a dlang.org PR

Safety is not what you think

2024-01-29 Thread user1234 via Digitalmars-d-learn
I want to share a stupid program to show you that D safety is more complex than you might think: ```d module test; void test() @safe { int i; int b = (*&(*&++i))++; } void main() @safe { test(); } ``` I'm not showing a deficiency of D, that program is undeniably safe ;)

Re: Function Composition

2024-01-24 Thread user1234 via Digitalmars-d-learn
On Wednesday, 24 January 2024 at 21:30:23 UTC, user1234 wrote: On Wednesday, 24 January 2024 at 21:12:20 UTC, atzensepp wrote: [...] what a bummer! Have you tried https://dlang.org/phobos/std_functional.html#compose ? Well this violates the second requirement: the composition itself

Re: Function Composition

2024-01-24 Thread user1234 via Digitalmars-d-learn
On Wednesday, 24 January 2024 at 21:12:20 UTC, atzensepp wrote: [...] what a bummer! Have you tried https://dlang.org/phobos/std_functional.html#compose ?

Re: Understanding the Use of Nested Import and Selective Import in D

2024-01-16 Thread user1234 via Digitalmars-d-learn
On Tuesday, 16 January 2024 at 13:37:59 UTC, user1234 wrote: Implementation detail. D frontend resolves identifiers using associative arrays (that's called symtabs in the compiler IIRC), hence the only complexity is the scope (plus the import decls found while going back to the module scope).

Re: Understanding the Use of Nested Import and Selective Import in D

2024-01-16 Thread user1234 via Digitalmars-d-learn
On Tuesday, 16 January 2024 at 13:19:59 UTC, Orfeo wrote: I found myself a bit perplexed when it comes to the usage of "nested imports" and selective imports. It seems that prominent D programmers have varied opinions on the matter. I would love to hear your insights and experiences on this

Re: `static` function ... cannot access variable in frame of ...

2024-01-15 Thread user1234 via Digitalmars-d-learn
On Monday, 15 January 2024 at 18:34:58 UTC, H. S. Teoh wrote: On Mon, Jan 15, 2024 at 06:16:44PM +, Bastiaan Veelo via Digitalmars-d-learn wrote: Hey people, I can use some help understanding why the last line produces a compile error. ```d import std.stdio; struct S { static void

Re: `static` function ... cannot access variable in frame of ...

2024-01-15 Thread user1234 via Digitalmars-d-learn
On Monday, 15 January 2024 at 18:16:44 UTC, Bastiaan Veelo wrote: [...] It seems to me this should just work. Thanks! --Bastiaan. The two calls are not equivalent. To be equivalent you need to set `S_foo` static too, otherwise `S_Foo` is instanciated in `main` scope, proof: ```d import

Re: Synchronisation help

2024-01-02 Thread user1234 via Digitalmars-d-learn
On Tuesday, 2 January 2024 at 11:39:12 UTC, Anonymouse wrote: On Tuesday, 2 January 2024 at 11:05:33 UTC, user1234 wrote: Do not use `shared` AA. Use `__gshared` + sync primitives. `shared` AA will lead to all sort of bugs: - https://issues.dlang.org/show_bug.cgi?id=20484#c1 -

Re: Synchronisation help

2024-01-02 Thread user1234 via Digitalmars-d-learn
On Monday, 1 January 2024 at 15:48:16 UTC, Anonymouse wrote: I have a `shared string[int]` AA that I access from two different threads. The function I spawn to start the second thread takes the AA as an argument. [...] What is the common solution here? Do I add a module-level `Object thing`

Re: Indirect access to variables.

2023-12-29 Thread user1234 via Digitalmars-d-learn
On Friday, 29 December 2023 at 17:11:49 UTC, DLearner wrote: Compile-time: [...] Is there a 'foo1' that yields 1 from the snippet below? [...] Similarly, execution-time, is there a foo2 that wields 2 from the snippet below: [...] **compile-tome** ```d void main() { import std.stdio;

Re: ImportC has improved macro support

2023-12-06 Thread user1234 via Digitalmars-d-announce
On Wednesday, 6 December 2023 at 20:26:38 UTC, Walter Bright wrote: The interesting thing here is `expression` does not need to be translated to D. It's still a C expression, and has C semantics. D templates with C semantics just falls out of the way ImportC was implemented. Indeed, I've

Re: How to hash SHA256 from string?

2023-12-02 Thread user1234 via Digitalmars-d-learn
On Saturday, 2 December 2023 at 16:17:08 UTC, user1234 wrote: On Saturday, 2 December 2023 at 15:30:39 UTC, zoujiaqing wrote: [...] sign is binary, you have to use the toHexString utility : ```d import std.stdio; import std.digest.sha; void main() { SHA256 sha256; sha256.start();

Re: How to hash SHA256 from string?

2023-12-02 Thread user1234 via Digitalmars-d-learn
On Saturday, 2 December 2023 at 15:30:39 UTC, zoujiaqing wrote: ```D import std.stdio; import std.digest.sha; void main() { SHA256 sha256; sha256.start(); string appKey = "1"; ubyte[1024] data =

Re: Inversion of conditional compilation statements

2023-12-02 Thread user1234 via Digitalmars-d-learn
On Saturday, 2 December 2023 at 13:16:26 UTC, Johannes Miesenhardt wrote: Hello, [...] I see the way why it doesn't work, but I think it should. Considering that `version (Test) {} else {` works without any issue but looks very ugly. Can somebody explain if this is an intended decision or

Re: Is a shorter statement possible in this case?

2023-11-05 Thread user1234 via Digitalmars-d-learn
On Sunday, 5 November 2023 at 18:36:40 UTC, Ctn-Dev wrote: I wrote this earlier: [...] if runs when both "One" and "Two" are in the given array as intended, but its conditional statement looks verbose. Is there a more concise way of getting the same result? Yes, assuming you accept to drop

Re: extern (c)

2023-10-11 Thread user1234 via Digitalmars-d-learn
On Wednesday, 11 October 2023 at 13:36:16 UTC, Paul wrote: On Wednesday, 11 October 2023 at 12:54:53 UTC, user1234 wrote: `extern(C)` on module level functions affect the mangling and the calling convention. - Mangling is used by the linker to link symbols between objects. - Calling

Re: extern (c)

2023-10-11 Thread user1234 via Digitalmars-d-learn
On Wednesday, 11 October 2023 at 12:36:58 UTC, Paul wrote: What does the extern (c) attribute(?) do? Does it tell the compiler/linker to build the function like a C compiler would build a C function? If so what does that mean? Does it tell the compiler/linker to let C functions know it exists?

Re: Getting all struct members and values with introspection avoiding string mixins

2023-10-05 Thread user1234 via Digitalmars-d-learn
On Thursday, 5 October 2023 at 22:24:06 UTC, mw wrote: On Thursday, 5 October 2023 at 21:41:38 UTC, cc wrote: If you have `T info`, T.tupleof[n] will always match up with info.tupleof[n]. You can think of `info.tupleof[n]` as being rewritten by the compiler in-place as

Re: How to get all modules in a package at CT?

2023-10-05 Thread user1234 via Digitalmars-d-learn
On Thursday, 5 October 2023 at 20:42:26 UTC, mw wrote: On Thursday, 5 October 2023 at 20:07:38 UTC, user1234 wrote: No. Sorry. Generally compile time code cannot interact with the system. To be evaluable at compile time code has to be strongly pure, that is not the case of the function you

Re: How to get all modules in a package at CT?

2023-10-05 Thread user1234 via Digitalmars-d-learn
On Thursday, 5 October 2023 at 18:40:36 UTC, mw wrote: On Saturday, 24 November 2018 at 15:21:57 UTC, Anonymouse wrote: On Saturday, 24 November 2018 at 08:44:19 UTC, Domain wrote: I have a package named command, and many modules inside it, such as command.build, command.pack, command.help...

Re: From the D Blog: Crafting Self-Evident Code in D

2023-10-03 Thread user1234 via Digitalmars-d-announce
On Monday, 2 October 2023 at 17:28:19 UTC, Mike Parker wrote: It's been a long, long while since I published anything on the blog. I do intend to get pick it up again down the road, but Walter recently surprised me with plans of his own. He's taken the topic of his DConf '23 talk and derived a

Re: parallelism with delegate

2023-09-21 Thread user1234 via Digitalmars-d-learn
On Friday, 22 September 2023 at 04:33:44 UTC, Vitaliy Fadeev wrote: On Friday, 22 September 2023 at 04:24:19 UTC, Vitaliy Fadeev wrote: ... Skip this thread. I see solution. How to delete missed posts on this forum ? It's there forever, you have to live with that error ;) See

Re: C to D: please help translate this weird macro

2023-09-21 Thread user1234 via Digitalmars-d-learn
On Thursday, 21 September 2023 at 16:28:25 UTC, Nick Treleaven wrote: (Untested) There might be a `need this` error

Re: Dinamyc arrays

2023-09-17 Thread user1234 via Digitalmars-d-learn
On Sunday, 17 September 2023 at 17:15:34 UTC, Timofey wrote: I`ve just started learning d and have a question. What should I write to set dinamyc rectangular array length in both dimentions? For example, I have declareted an array: ```d int[][] matrix; ``` and want set it as n*n matrix.

Re: pipeProcess output to hash string

2023-09-12 Thread user1234 via Digitalmars-d-learn
On Monday, 11 September 2023 at 22:08:54 UTC, Christian Köstlin wrote: Just three remarks: First I would recommend to use `std.process : execute` instead of `pipeProcess` in this usecase, as this will wait properly for the process to exit and it also will collect its output. Second its

Re: pipeProcess output to hash string

2023-09-09 Thread user1234 via Digitalmars-d-learn
On Saturday, 9 September 2023 at 15:44:44 UTC, Vino wrote: Hi All, Request your help on how to convert the output of std.process.pipeProcess to hash string ``` auto test(in Redirect redirect=Redirect.stdout | Redirect.stderr) { import std.process; import std.digest.crc;

Re: Warning for anyone who was at DConf.

2023-09-04 Thread user1234 via Digitalmars-d-announce
On Sunday, 3 September 2023 at 17:46:28 UTC, ryuukk_ wrote: On Saturday, 2 September 2023 at 20:41:33 UTC, Dukc wrote: Just a while ago I was hit by some sort of a violent ailment. I first noticed it like an hour ago, and I'm shivering as I stand in a well-heated house, despite having had a

Re: Is sizeof() available in D language?

2023-09-04 Thread user1234 via Digitalmars-d-learn
On Monday, 4 September 2023 at 09:41:54 UTC, BoQsc wrote: I've seen everyone using **datatype**`.sizeof` property. https://dlang.org/spec/property.html#sizeof It's great, but I wonder if it differ in any way from the standard C function `sizeof()`.

Re: Cool pattern or tragic?

2023-08-26 Thread user1234 via Digitalmars-d-learn
On Friday, 25 August 2023 at 21:00:08 UTC, Guillaume Piolat wrote: The idea is to deliberately mark @system functions that need special scrutiny to use, regardless of their memory-safety. Function that would typically be named `assumeXXX`. ```d class MyEncodedThing { Encoding encoding;

Re: Implicit type conversion depending on assignment

2023-03-23 Thread user1234 via Digitalmars-d-learn
On Thursday, 23 March 2023 at 14:17:25 UTC, user1234 wrote: not exactly thing goal yet. The doc example you have put a link for is different, the struct with alias this a redefinition of the "alias this"'ed thing, that just cant work in what you ask in the first post. omg, let's rewrite

Re: Implicit type conversion depending on assignment

2023-03-23 Thread user1234 via Digitalmars-d-learn
On Thursday, 23 March 2023 at 14:05:07 UTC, Alexander Zhirov wrote: On Thursday, 23 March 2023 at 13:38:51 UTC, Alexander Zhirov wrote: Is it possible to convert such records inside the structure to the assigned type? ```d struct MyVal { string value; // Here it would be possible to

Re: Preventing the Compiler from Optimizing Away Benchmarks

2023-03-13 Thread user1234 via Digitalmars-d-learn
On Monday, 13 March 2023 at 14:17:57 UTC, jmh530 wrote: I was looking at [1] for ways to prevent the compiler from optimizing away code when trying to benchmark. It has the following C++ code as a simpler version: ``` inline BENCHMARK_ALWAYS_INLINE void DoNotOptimize(Tp& value) { asm

Re: Can nice D code get a bit slow?

2023-03-09 Thread user1234 via Digitalmars-d-learn
On Wednesday, 8 March 2023 at 12:46:53 UTC, Hipreme wrote: On Wednesday, 8 March 2023 at 10:49:32 UTC, Markus wrote: Hi, sorry for the broad and vague question. I have read in some reddit post about benchmarks, that some code didn't use the final keyword on methods in a sense that final would

Re: Template alias parameter: error: need 'this' for ...

2023-02-24 Thread user1234 via Digitalmars-d-learn
On Friday, 24 February 2023 at 12:00:41 UTC, Elfstone wrote: Seems like the same bug is still there after ten years. ```d struct Bar { @("hello") int t; } static bool hasAttribute(alias F, T)() { bool result = false;

Re: ELIZA Chatbot Implementation From C to D Lang

2023-02-18 Thread user1234 via Digitalmars-d-learn
On Friday, 17 February 2023 at 17:03:34 UTC, ron77 wrote: Hello, I succeeded in converting an ELIZA code from C to D, and here are the results. although I'm sure there are better ways to code it or to convert it... [...] Among the things to do the first is to drop C-style strings, so that

Re: compile: link dynamic OR static library in Windows

2023-02-05 Thread user1234 via Digitalmars-d-learn
On Sunday, 5 February 2023 at 11:52:01 UTC, Alexander Zhirov wrote: On Saturday, 4 February 2023 at 15:56:41 UTC, Richard (Rikki) Andrew Cattermole wrote: [...] I don't understand why the compiler doesn't see the library. ```sh User@WIN-D3SHRBHN7F6 MINGW64 /home/user/pxe-restore/source # ls

Re: _Symbols _with _leading _underscores

2022-12-16 Thread user1234 via Digitalmars-d-learn
On Saturday, 17 December 2022 at 02:42:22 UTC, Paul wrote: I see code like this from time to time. Are the leading underscores significant, in general, in the D language? Is it just programmer preference? Is it a coding practice, in general, that is common...even outside of D? Thanks for

Re: How to pass noncopyable variadic arguments with ref?

2022-10-20 Thread user1234 via Digitalmars-d-learn
On Thursday, 20 October 2022 at 16:34:34 UTC, user1234 wrote: On Thursday, 20 October 2022 at 14:03:10 UTC, tchaloupka wrote: Hi, I've found strange behavior where: [...] Shouldn't it at least protest that objects can't be passed to the function as they aren't copyable? it's clearly a

Re: How to pass noncopyable variadic arguments with ref?

2022-10-20 Thread user1234 via Digitalmars-d-learn
On Thursday, 20 October 2022 at 14:03:10 UTC, tchaloupka wrote: Hi, I've found strange behavior where: [...] Shouldn't it at least protest that objects can't be passed to the function as they aren't copyable? it's clearly a compiler bug to me. Something is not checked when the call is

Re: A new Tree-Sitter Grammar for D

2022-10-17 Thread user1234 via Digitalmars-d-announce
On Monday, 17 October 2022 at 06:24:08 UTC, Vladimir Panteleev wrote: On Monday, 17 October 2022 at 05:21:10 UTC, Garrett D'Amore wrote: I'm happy to announce that I've created what I believe is a complete, or at least very nearly so, Tree-Sitter grammar for D. You can find it at

Re: Generate a pointer to a method of a struct

2022-10-15 Thread user1234 via Digitalmars-d-learn
On Saturday, 15 October 2022 at 01:48:15 UTC, kdevel wrote: Is this consistent? I think all the compilers should error on expressions like `Type.nonStaticMethod` and instead there should be a new __traits dedicated to that, especially because `this` is not a formal parameter.

Re: How to workaround assignment not allowed in a condition?

2022-10-12 Thread user1234 via Digitalmars-d-learn
On Wednesday, 12 October 2022 at 02:15:55 UTC, Steven Schveighoffer wrote: Porting some C code to D This results in an error: ```d int x; while(!(x = 5)) { break; } ``` Error is: assignment cannot be used as a condition, perhaps `==` was meant? ... I think D should relax the restriction

Re: Example for multi level template composition

2022-10-10 Thread user1234 via Digitalmars-d-learn
On Monday, 10 October 2022 at 06:30:05 UTC, Arun wrote: Stumbled upon this question on HN https://news.ycombinator.com/item?id=33142751#33147401 Can I write template A and then apply it to itself to get template B and then apply that onto template C to get template D. Does anyone have an

Re: Explicit cast to @system?

2022-10-09 Thread user1234 via Digitalmars-d-learn
On Saturday, 8 October 2022 at 23:06:13 UTC, Anonymouse wrote: I have some nested templated code that takes function pointers. In many cases I pass it functions of identical signatures, except some are `@safe` and others are `@system`. In those cases the templates end up getting instantiated

Re: cannot gdb LDC build binary: Segmentation fault

2022-10-08 Thread user1234 via Digitalmars-d-learn
On Friday, 7 October 2022 at 04:40:34 UTC, mw wrote: Hi, I have a LDC (1.30.0) built binary on Ubuntu 18.04.5 LTS x86_64, the program core dumps somewhere, so I want to debug it. However under gdb, the program fails as soon as I start it: [...] Try the non-stop mode maybe :

Re: to delete the '\0' characters

2022-09-22 Thread user1234 via Digitalmars-d-learn
On Thursday, 22 September 2022 at 10:53:32 UTC, Salih Dincer wrote: Is there a more accurate way to delete the '\0' characters at the end of the string? I tried functions in this module: https://dlang.org/phobos/std_string.html ```d auto foo(string s) { string r; foreach(c; s) {

Re: Validate static asserts

2022-09-09 Thread user1234 via Digitalmars-d-learn
On Friday, 9 September 2022 at 17:35:44 UTC, Dennis wrote: On Friday, 9 September 2022 at 16:41:54 UTC, Andrey Zherikov wrote: What's about new `compileOutput` trait that returns compiler output? ```d static assert(__traits(compileOutput, { }) == "message"); ``` As a compiler dev, that

Re: Programs in D are huge

2022-08-16 Thread user1234 via Digitalmars-d-learn
On Tuesday, 16 August 2022 at 08:25:18 UTC, Diego wrote: Hello everyone, I'm a Java programmer at work but i'm learning D for pleasure. I'm reading _The D Programming Language by Ali Çehreli_. I noticed that DMD creates very huge executable, for example an empty program: ``` empty.d:

Re: code review: splitIds from DConf '22 day 3: saving a sort and "getting performance"

2022-08-05 Thread user1234 via Digitalmars-d-learn
On Thursday, 4 August 2022 at 13:18:40 UTC, kdevel wrote: At DConf '22 day 3 Robert Schadek presented at around 07:22:00 in the YT video the function `splitIds`. Given an HTML page from bugzilla containing a list of issues `splitIds` aims at extracting all bug-ids referenced within a specific

Re: Build for i586

2022-07-28 Thread user1234 via Digitalmars-d-learn
On Thursday, 28 July 2022 at 06:12:49 UTC, Alexander Zhirov wrote: On Thursday, 28 July 2022 at 06:01:17 UTC, Alexander Zhirov > x86- 32-bit X86: Pentium-Pro and above I also tried with `i586` and `pentium` - the result is the same. Pentium Pro and above means at least i686. i586 is

Re: Build for i586

2022-07-28 Thread user1234 via Digitalmars-d-learn
On Thursday, 28 July 2022 at 07:16:13 UTC, user1234 wrote: On Thursday, 28 July 2022 at 06:12:49 UTC, Alexander Zhirov wrote: [...] Pentium Pro and above means at least i686. i586 is Pentium1 which is less featured. That means that you cant do much, however you can try to tune the i686

Re: null == "" is true?

2022-07-12 Thread user1234 via Digitalmars-d-learn
On Tuesday, 12 July 2022 at 19:55:46 UTC, ag0aep6g wrote: On Tuesday, 12 July 2022 at 19:02:01 UTC, user1234 wrote: On Tuesday, 12 July 2022 at 16:40:38 UTC, H. S. Teoh wrote: [...] Do not rely on this, however; Absolutely. I'd like to add: especially as default parameter value that's an

Re: null == "" is true?

2022-07-12 Thread user1234 via Digitalmars-d-learn
On Tuesday, 12 July 2022 at 16:40:38 UTC, H. S. Teoh wrote: On Tue, Jul 12, 2022 at 04:27:44PM +, Antonio via Digitalmars-d-learn wrote: It works ```d void main() { assert(null==""); } ``` why? Because an empty string is, by default, represented by an empty slice of the null

Re: The D Programming Language Vision Document

2022-07-04 Thread user1234 via Digitalmars-d-announce
On Monday, 4 July 2022 at 05:51:48 UTC, Andrej Mitrovic wrote: On Monday, 4 July 2022 at 05:35:20 UTC, rikki cattermole wrote: On 04/07/2022 5:30 PM, Andrej Mitrovic wrote: Aren't these the polar opposites of each other? The GC is one of D's strengths, yet we should avoid it as much as

Re: The D Programming Language Vision Document

2022-07-03 Thread user1234 via Digitalmars-d-announce
On Sunday, 3 July 2022 at 18:33:29 UTC, rikki cattermole wrote: Its just an unnecessary goal, when most of the string algorithms we have probably don't care about the encoding and those that do probably will be using dstrings. To the contrary, I find this goal coherant with the end of

Re: How to check if something can be null

2022-07-01 Thread user1234 via Digitalmars-d-learn
On Friday, 1 July 2022 at 13:53:28 UTC, Antonio wrote: On Friday, 1 July 2022 at 13:48:25 UTC, Antonio wrote: -Why? I realized Json is an struct (not an object)... and I supose, it is managing null asignation manually (as a way to build Json(null)). -Whats the correct whay to test if

Re: New forum view mode "narrow-index" is now available

2022-06-30 Thread user1234 via Digitalmars-d-announce
On Thursday, 30 June 2022 at 07:09:36 UTC, Ahmet Sait wrote: Hi everyone, There is a new view mode you can check out under settings, designed to be more usable for narrow screens (such as smart phones). This setting is stored client side as a cookie which means you can use it on your phone

Re: Bug in dmd?

2022-06-15 Thread user1234 via Digitalmars-d-learn
On Tuesday, 14 June 2022 at 13:39:12 UTC, Andrey Zherikov wrote: I have [pretty simple code in my library](https://github.com/andrey- [Line (2) produces](https://github.com/andrey-zherikov/argparse/runs/6880350900?check_suite_focus=true#step:5:12) `undefined reference to

Re: Generating unique identifiers at compile time

2022-06-13 Thread user1234 via Digitalmars-d-learn
On Monday, 13 June 2022 at 07:38:54 UTC, user1234 wrote: On Thursday, 9 June 2022 at 23:50:10 UTC, user1234 wrote: On Thursday, 9 June 2022 at 21:20:27 UTC, JG wrote: [...] No, for now there if there are other ways they are as hacky as yours. The compiler usually uses a global counter to

Re: Generating unique identifiers at compile time

2022-06-13 Thread user1234 via Digitalmars-d-learn
On Thursday, 9 June 2022 at 23:50:10 UTC, user1234 wrote: On Thursday, 9 June 2022 at 21:20:27 UTC, JG wrote: [...] No, for now there if there are other ways they are as hacky as yours. The compiler usually uses a global counter to generate temporaries. There's [been attempts] to expose

Re: Generating unique identifiers at compile time

2022-06-09 Thread user1234 via Digitalmars-d-learn
On Thursday, 9 June 2022 at 21:20:27 UTC, JG wrote: Hi, As an experiment I have implemented the following kind of pattern matching (by parsing the part of the string before '='). ```d struct S { int x; int y; } struct T { int w; S s; } void main() { mixin(matchAssign(q{auto

Re: D at BSDCan

2022-05-30 Thread user1234 via Digitalmars-d-announce
On Sunday, 29 May 2022 at 20:57:56 UTC, Brian Callahan wrote: Hi all -- I'm giving a redux of my PolyglotBSD talk at BSDCan this year: https://www.bsdcan.org/events/bsdcan_2022/schedule/session/96-polyglotbsd/ It's virtual, so feel free to come by. It won't be all about D, but D is a major

Re: Why is the compiled file size so huge?

2022-05-28 Thread user1234 via Digitalmars-d-learn
On Friday, 27 May 2022 at 13:40:25 UTC, Alexander Zhirov wrote: I'm trying to compile a file that weighs 3 kilobytes. I'm also linking a self-written dynamic library. I don't understand why the resulting executable file is so huge? After all, all libraries are present: I'd take a look with

Re: Inferred attributes errors in template function.

2022-05-27 Thread user1234 via Digitalmars-d-learn
On Friday, 27 May 2022 at 09:41:32 UTC, user1234 wrote: [...] on a side note that's funny how dmd manages to systematically print the less interesting message in both case. They are actually correct, I dont know why at some point I thought there was a problem. For the float one it's

Re: Inferred attributes errors in template function.

2022-05-27 Thread user1234 via Digitalmars-d-learn
On Friday, 27 May 2022 at 08:39:08 UTC, vit wrote: Hello, I have this problem: ```d static int i; void bar(T)(){ static if(is(T == int)) (()@system => 1)(); static if(is(T == float)) i = 42; } void foo(T)(){ bar!T(); } void main()@safe pure{

Re: Cannot check function address

2022-05-25 Thread user1234 via Digitalmars-d-learn
On Wednesday, 25 May 2022 at 06:04:10 UTC, frame wrote: On Wednesday, 25 May 2022 at 05:56:28 UTC, Steven Schveighoffer wrote: It's a case where the compiler can't divine what you were thinking when you wrote that code ;) I see not in all cases but in mine. If the compiler sees the

Re: Odd construct idea. Splitting arguments inside a parameter list.

2022-05-23 Thread user1234 via Digitalmars-d-learn
On Monday, 23 May 2022 at 08:53:27 UTC, user1234 wrote: On Monday, 23 May 2022 at 08:52:12 UTC, vit wrote: On Monday, 23 May 2022 at 08:34:21 UTC, Chris Katko wrote: D struct pair { float x,y; } [...] This work too: ```d myFunction(taco, p.tupleof, burrito); ``` and you can pass a

Re: Odd construct idea. Splitting arguments inside a parameter list.

2022-05-23 Thread user1234 via Digitalmars-d-learn
On Monday, 23 May 2022 at 08:52:12 UTC, vit wrote: On Monday, 23 May 2022 at 08:34:21 UTC, Chris Katko wrote: D struct pair { float x,y; } [...] This work too: ```d myFunction(taco, p.tupleof, burrito); ``` and you can pass a std.typecons.Tuple as well, it will expand x y

Re: template? mixin? template mixins? for modifying a struct setup

2022-05-19 Thread user1234 via Digitalmars-d-learn
On Thursday, 19 May 2022 at 10:15:32 UTC, Chris Katko wrote: given ```D struct COLOR { float r, g, b, a; // a is alpha (opposite of transparency) } auto red = COLOR(1,0,0,1); auto green = COLOR(0,1,0,1); auto blue = COLOR(0,0,1,1); auto white = COLOR(1,1,1,1); //etc ``` is there a way to

Re: String Literals

2022-05-03 Thread user1234 via Digitalmars-d-learn
On Tuesday, 3 May 2022 at 17:21:47 UTC, JG wrote: Hi, The specification of string literals has either some errors or I don't understand what is meant by a Character. [...] Which to me means that e.g. r""" should be a WysiwygString, which the compiler thinks is not (not surprisingly). Am I

Re: Classes in D with betterC

2022-05-01 Thread user1234 via Digitalmars-d-announce
On Monday, 2 May 2022 at 01:03:59 UTC, user1234 wrote: On Sunday, 1 May 2022 at 19:51:19 UTC, Test123 wrote: Is there any example how to use betterC with LLVM Style RTTI ? The basic blocks: - you need an allocator that places RTTI after the instances - you need an helper func that retrieve

Re: Classes in D with betterC

2022-05-01 Thread user1234 via Digitalmars-d-announce
On Sunday, 1 May 2022 at 19:51:19 UTC, Test123 wrote: Is there any example how to use betterC with LLVM Style RTTI ? The basic blocks: - you need an allocator that places RTTI after the instances - you need an helper func that retrieve the RTTI ```d #!dmd -betterC module runnable; import

Re: generic function instance without call

2022-04-27 Thread user1234 via Digitalmars-d-learn
On Wednesday, 27 April 2022 at 17:22:14 UTC, vit wrote: This work for types but not for attributes like `scope`, `return` and `auto ref`. Oh sorry... auto ref... I totally forgot [this old bug] [this old bug]: https://issues.dlang.org/show_bug.cgi?id=8204

Re: generic function instance without call

2022-04-27 Thread user1234 via Digitalmars-d-learn
On Wednesday, 27 April 2022 at 15:23:26 UTC, vit wrote: Hi, is it possible to get address of generic function instance for specified arguments without calling the function? Example: ```d auto foo(alias fn, Args...)(auto ref Args args){ ///return function/delegate type of `fn` for

Re: A template construct like using()

2022-04-27 Thread user1234 via Digitalmars-d-learn
On Tuesday, 26 April 2022 at 21:33:43 UTC, Chris Katko wrote: I swear I asked something like this before years ago but it doesn't show up in my previous forum posts. I'm looking for a construct that mimics using(var)/with(var) ```D bitmap* b; draw_with(b) { draw_pixel(red, 16, 16);

Re: Create a wrapper around larger c-libraries

2022-04-24 Thread user1234 via Digitalmars-d-learn
On Sunday, 24 April 2022 at 15:13:15 UTC, Alain De Vos wrote: I'm currenlty experimenting about binding to C. I have : C-library: mylib.h: ``` void libprintme(char *s); ``` mylib.c: ``` #include #include "mylib.h" void libprintme(char *s){printf("%s",s);} ``` [...] Can this procedure be

Re: Beta 2.100.0

2022-04-22 Thread user1234 via Digitalmars-d-announce
On Friday, 22 April 2022 at 09:55:22 UTC, rikki cattermole wrote: This release is very exciting. Semver versioning, it just took 100 releases to accidentaly match the standards. What a marathon.

Re: Adding Modules to C in 10 Lines of Code

2022-04-19 Thread user1234 via Digitalmars-d-announce
On Sunday, 17 April 2022 at 20:12:38 UTC, Walter Bright wrote: https://nwcpp.org/ An online presentation. Monday at 7PM PST. I thought to that when you made this, a few weeks ago, for importC: "that's 10 lines because module system is already backed by D system of scopes, symbol lookups(,

Re: Static struct initialization syntax behavior & it being disabled upon adding a constructor

2022-04-18 Thread user1234 via Digitalmars-d-learn
On Monday, 18 April 2022 at 10:26:16 UTC, HuskyNator wrote: On a sidenote, I'm surprised D did not choose 0 as the default floating value. Doesn't almost every language do this? I understand the thinking behind it, but when the type one uses in a template influences the behavior of the code,

Re: How to use Vector Extensions in an opBinary

2022-04-17 Thread user1234 via Digitalmars-d-learn
On Sunday, 17 April 2022 at 11:16:25 UTC, HuskyNator wrote: I recently found out there is [support for vector extensions](https://dlang.org/spec/simd.html) But I have found I don't really understand how to use it, not even mentioning the more complex stuff. I couldn't find any good examples

Re: Lambdas Scope

2022-04-11 Thread user1234 via Digitalmars-d-learn
On Monday, 11 April 2022 at 09:11:06 UTC, Salih Dincer wrote: How is this possible? Why is it compiled? Don't the same names in the same scope conflict? ```d int function(int) square; void main() { square = (int a) => a * a; int square = 5.square; assert(square == 25); } ``` Thanks,

Re: Why do immutable variables need reference counting?

2022-04-11 Thread user1234 via Digitalmars-d-learn
On Sunday, 10 April 2022 at 23:05:24 UTC, norm wrote: Hi All, I am clearly misunderstanding something fundamental, and probably obvious :D Reading some of the discussions on __metadata I was wondering if someone could explain why a immutable reference counting type is needed. By definition

Re: Where I download Digital Mars C Preprocessor sppn.exe?

2022-04-03 Thread user1234 via Digitalmars-d-learn
On Saturday, 2 April 2022 at 21:57:02 UTC, Marcone wrote: Where I download Digital Mars C Preprocessor sppn.exe? I need it to use ImportC it's part of the [DMC] toolchain. [DMC]: http://ftp.digitalmars.com/Digital_Mars_C++/Patch/dm857c.zip

Re: Nested Classes with inheritance

2022-03-19 Thread user1234 via Digitalmars-d-learn
On Saturday, 19 March 2022 at 05:25:01 UTC, Era Scarecrow wrote: On Saturday, 19 March 2022 at 00:16:48 UTC, user1234 wrote: That crashes because of the creation of `Bar b` member, which itself has a Bar b member, which itself... Mhmm... So There's Foo with Bar b, which has Bar b which has

Re: Nested Classes with inheritance

2022-03-18 Thread user1234 via Digitalmars-d-learn
On Saturday, 19 March 2022 at 00:05:54 UTC, Salih Dincer wrote: Greetings to all... There are nested classes as below. But beware, there's also inheritance, extra! If you construct ```Bar b``` from main(), it's okay. But if declare the constructor in Foo(), the program crashes with a

  1   2   3   4   >