Re: vibe.d requestHTTP in static this causes infinite loop?

2022-05-20 Thread bauss via Digitalmars-d-learn
On Friday, 20 May 2022 at 01:41:59 UTC, Ali Çehreli wrote: On 5/19/22 16:44, Vijay Nayar wrote: > If I remove the call from `static this()`, then the web call works as > normal. Any idea why calling vibe.d's `requestHTTP` function inside of a > module's static construction would cause an

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

2022-05-19 Thread bauss via Digitalmars-d-learn
On Thursday, 19 May 2022 at 10:18:38 UTC, user1234 wrote: 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);

Re: class destructors must be @disabled?

2022-05-19 Thread bauss via Digitalmars-d-learn
On Wednesday, 18 May 2022 at 19:58:09 UTC, Ali Çehreli wrote: Hmm. Perhaps the guideline should be "all destructors must be @nogc". Ali It should probably just default to that and with no exception, since you will never end up in a situation where you don't want @nogc for a destructor.

Re: Unexplainable behaviour with direct struct assignment.

2022-05-19 Thread bauss via Digitalmars-d-learn
On Wednesday, 18 May 2022 at 21:52:18 UTC, HuskyNator wrote: On Wednesday, 18 May 2022 at 21:49:14 UTC, HuskyNator wrote: After updating to `DMD 2.100.0` & `DUB 1.29.0`, I still get this behavior. Only when I use `dub run --b=debug` however (default for me). `dub run --b=release` does return

Re: I need to use delete as the method name. But now it's still a keyword, right?

2022-05-19 Thread bauss via Digitalmars-d-learn
On Wednesday, 18 May 2022 at 15:33:09 UTC, Steven Schveighoffer wrote: On 5/18/22 2:13 AM, bauss wrote: On Wednesday, 18 May 2022 at 02:12:42 UTC, zoujiaqing wrote: https://dlang.org/changelog/2.100.0.html#deprecation_delete My code: ```D import std.stdio; class HttpClient { string

Re: I need to use delete as the method name. But now it's still a keyword, right?

2022-05-18 Thread bauss via Digitalmars-d-learn
On Wednesday, 18 May 2022 at 02:12:42 UTC, zoujiaqing wrote: https://dlang.org/changelog/2.100.0.html#deprecation_delete My code: ```D import std.stdio; class HttpClient { string get(string url) { return ""; } string delete(string url)

Re: What are (were) the most difficult parts of D?

2022-05-17 Thread bauss via Digitalmars-d-learn
On Tuesday, 17 May 2022 at 11:53:40 UTC, zjh wrote: On Tuesday, 17 May 2022 at 11:50:30 UTC, zjh wrote: Right,GC is a bad idea! Endless use of memory without freeing. It's totally unreasonable waste. It's not really endless use of memory and it does free. Depending on the strategy then it

Re: Question on shapes

2022-05-17 Thread bauss via Digitalmars-d-learn
On Tuesday, 17 May 2022 at 00:10:55 UTC, Alain De Vos wrote: Let's say a shape is ,a circle with a radius ,or a square with a rectangular size. I want to pass shapes to functions, eg to draw them on the screen, draw(myshape) or myshape.draw(); But how do i implement best shapes ? In addition

Re: decimal type in d

2022-05-16 Thread bauss via Digitalmars-d-learn
On Monday, 16 May 2022 at 09:46:57 UTC, IGotD- wrote: On Sunday, 15 May 2022 at 13:26:30 UTC, vit wrote: Hello, I want read decimal type from sql db, do some arithmetic operations inside D program and write it back to DB. Result need to be close to result as if this operations was performed

Re: Why are structs and classes so different?

2022-05-16 Thread bauss via Digitalmars-d-learn
On Sunday, 15 May 2022 at 15:59:17 UTC, Alain De Vos wrote: Can i summarize , structs are value-objects which live on the stack. class instances are reference objects which live on the heap. But that's not entirely true as you can allocate a struct on the heap as well. The real difference

Re: What are (were) the most difficult parts of D?

2022-05-11 Thread bauss via Digitalmars-d-learn
On Wednesday, 11 May 2022 at 05:41:35 UTC, Ali Çehreli wrote: What are you stuck at? What was the most difficult features to understand? etc. To make it more meaningful, what is your experience with other languages? Ali dip1000

Re: Parameters declared as the alias of a template won't accept the arguments of the same type.

2022-05-04 Thread bauss via Digitalmars-d-learn
On Tuesday, 3 May 2022 at 07:11:48 UTC, Ola Fosheim Grøstad wrote: As you see, someone will have to write a DIP to fix this bug, as the language authors don't consider it a bug, but an enhancement. I don't believe those two words are mutually exclusive. It can be a bug __and__ an

Re: How to get compatible symbol names and runtime typeid names for templated classes?

2022-05-03 Thread bauss via Digitalmars-d-learn
On Tuesday, 3 May 2022 at 09:52:56 UTC, cc wrote: On Tuesday, 3 May 2022 at 09:42:45 UTC, cc wrote: Given a runtime typeid, how can I get the equivalent fullyQualifiedName without attempting to mangle the string myself manually? e.g. something I can pass to `Object.factory`. Actually,

Re: CTFE and BetterC compatibility

2022-04-28 Thread bauss via Digitalmars-d-learn
On Thursday, 28 April 2022 at 12:36:56 UTC, Dennis wrote: On Thursday, 28 April 2022 at 12:10:44 UTC, bauss wrote: On Wednesday, 27 April 2022 at 15:40:49 UTC, Adam D Ruppe wrote: but this got killed due to internal D politics. A pity. A tale as old as time itself In this case, it was

Re: CTFE and BetterC compatibility

2022-04-28 Thread bauss via Digitalmars-d-learn
On Wednesday, 27 April 2022 at 15:40:49 UTC, Adam D Ruppe wrote: but this got killed due to internal D politics. A pity. A tale as old as time itself

Re: How to implement private constructor

2022-04-25 Thread bauss via Digitalmars-d-learn
On Monday, 25 April 2022 at 07:18:44 UTC, bauss wrote: On Monday, 25 April 2022 at 00:18:03 UTC, Vinod K Chandran wrote: Hi all, Please take a look at this code. Is this the right way to use private constructors ? ```d class Foo { int p1 ; string p2 ; bool p3 ; private

Re: How to implement private constructor

2022-04-25 Thread bauss via Digitalmars-d-learn
On Monday, 25 April 2022 at 00:18:03 UTC, Vinod K Chandran wrote: Hi all, Please take a look at this code. Is this the right way to use private constructors ? ```d class Foo { int p1 ; string p2 ; bool p3 ; private this(int a, string b, bool c) { this.p1 = a

Re: stack frame & dangling pointer weirdness

2022-04-21 Thread bauss via Digitalmars-d-learn
On Thursday, 21 April 2022 at 05:49:12 UTC, Alain De Vos wrote: Following program: ``` import std.stdio; void main() @trusted { int *p=null; void myfun(){ int x=2; p= writeln(p); writeln(x); } myfun(); *p=16; writeln(p); writeln(*p); } ``` outputs :

Re: Beginner memory question.

2022-04-19 Thread bauss via Digitalmars-d-learn
On Saturday, 16 April 2022 at 20:48:15 UTC, Adam Ruppe wrote: On Saturday, 16 April 2022 at 20:41:25 UTC, WhatMeWorry wrote: Is virtual memory entering into the equation? Probably. Memory allocated doesn't physically exist until written to a lot of the time. You can also exceed your RAM in

Re: DUB issues

2022-04-19 Thread bauss via Digitalmars-d-learn
On Tuesday, 19 April 2022 at 09:37:49 UTC, Mike Parker wrote: On Tuesday, 19 April 2022 at 08:58:02 UTC, bauss wrote: On Monday, 18 April 2022 at 13:41:04 UTC, Mike Parker wrote: On Monday, 18 April 2022 at 05:27:32 UTC, Danny Arends wrote: Any ideas how to get into contact/fix this issue ?

Re: DUB issues

2022-04-19 Thread bauss via Digitalmars-d-learn
On Monday, 18 April 2022 at 13:41:04 UTC, Mike Parker wrote: On Monday, 18 April 2022 at 05:27:32 UTC, Danny Arends wrote: Any ideas how to get into contact/fix this issue ? I've emailed Sönke and pointed him to this thread. Wouldn't the appropriate thing to do be dub being officially a

Re: save and load a 2d array to a file

2022-04-19 Thread bauss via Digitalmars-d-learn
On Tuesday, 19 April 2022 at 06:05:27 UTC, Ali Çehreli wrote: int i = 42; file.rawWrite(*cast((int[1]*)())); // Casted to be an array of 1 I assume since we don't have a rawWriteValue, that it's rarely needed. However it should be fairly trivial like: void rawWriteValue(T)(T

Re: How to exclude function from being imported in D language?

2022-03-18 Thread bauss via Digitalmars-d-learn
On Friday, 18 March 2022 at 03:24:10 UTC, Era Scarecrow wrote: On Tuesday, 8 March 2022 at 22:28:27 UTC, bauss wrote: What D just needs is a way to specify the entry point, in which it just defaults to the first main function found, but could be any function given. Which is similar to what

Re: Make shared static this() encoding table compilable

2022-03-14 Thread bauss via Digitalmars-d-learn
On Monday, 14 March 2022 at 09:40:00 UTC, zhad3 wrote: Hey everyone, I am in need of some help. I have written this Windows CP949 encoding table https://github.com/zhad3/zencoding/blob/main/windows949/source/zencoding/windows949/table.d which is used to convert CP949 to UTF-16. After some

Re: Template with default parameter

2022-03-11 Thread bauss via Digitalmars-d-learn
On Friday, 11 March 2022 at 11:55:24 UTC, Andrey Zherikov wrote: On Friday, 11 March 2022 at 07:06:15 UTC, bauss wrote: Create an alias for T!() is the best you can do. Ex. ``` alias t = T!(); ``` There isn't really any better method as far as I know. I'd like to preserve the name (`t` !=

Re: Template with default parameter

2022-03-10 Thread bauss via Digitalmars-d-learn
On Friday, 11 March 2022 at 04:41:40 UTC, Andrey Zherikov wrote: I have simple template: ```d template T(int i=3) { mixin template M(int m) { enum t = i; } } { mixin T!1.M!1; pragma(msg, t); // 1 } { mixin T!().M!1; pragma(msg, t); //

Re: How to exclude function from being imported in D language?

2022-03-08 Thread bauss via Digitalmars-d-learn
On Tuesday, 8 March 2022 at 20:12:40 UTC, BoQsc wrote: I think D Language needs and lacks conditional compilation condition and attribute of "exclude". The exclude keyword or code block in the exclude, would be made sure to not be imported by any means. Now it seems all to be only workarounds.

Re: opCast in class prevents destroy

2022-03-01 Thread bauss via Digitalmars-d-learn
On Tuesday, 1 March 2022 at 08:16:13 UTC, Mike Parker wrote: On Tuesday, 1 March 2022 at 07:16:11 UTC, bauss wrote: Right now if you want to add an additional cast then you have to implement ALL the default behaviors and then add your custom cast. It's two template functions like the OP

Re: opCast in class prevents destroy

2022-02-28 Thread bauss via Digitalmars-d-learn
On Tuesday, 1 March 2022 at 04:59:49 UTC, Mike Parker wrote: It makes sense to me, and I would say the bug is that it's not documented. Personally it doesn't make sense to me. I don't think it should override default behaviors, but just add onto it, so you can add an additional cast.

Re: Odd behaviour of std.range

2022-02-22 Thread bauss via Digitalmars-d-learn
On Tuesday, 22 February 2022 at 12:48:21 UTC, frame wrote: What am I missing here? Is this some UTF conversion issue? ```d string a; char[] b; pragma(msg, typeof(a.take(1).front)); // dchar pragma(msg, typeof(b.take(1).front)); // dchar ``` Welcome to the world of auto decoding, D's million

Re: Is there a way to not escape slashes when parsing JSON?

2022-02-21 Thread bauss via Digitalmars-d-learn
On Monday, 21 February 2022 at 15:13:52 UTC, Kagamin wrote: On Monday, 21 February 2022 at 09:04:06 UTC, bauss wrote: Why are we even escaping them by default, it should be the other way around, that slashes are only escaped if you ask for it; that's how it literally is in almost every JSON

Re: Why writeln can't be converted to nothrow with just catching of StdioException

2022-02-21 Thread bauss via Digitalmars-d-learn
On Monday, 21 February 2022 at 10:57:07 UTC, Basile B. wrote: On Monday, 21 February 2022 at 10:53:56 UTC, Basile B. wrote: On Monday, 21 February 2022 at 10:49:13 UTC, partypooper wrote: Do I completely not understand what is `nothrow` or why I can't make function nothrow with just catching

Re: Is there a way to not escape slashes when parsing JSON?

2022-02-21 Thread bauss via Digitalmars-d-learn
On Monday, 21 February 2022 at 03:42:55 UTC, bachmeier wrote: I tried this ``` import std.json, std.stdio; void main() { writeln(parseJSON(`{"a": "path/file"}`, JSONOptions.doNotEscapeSlashes)); } ``` but the output is ``` {"a":"path\/file"} ``` Is there a way to avoid the escaping of

Re: How to update Associative Array?

2022-02-10 Thread bauss via Digitalmars-d-learn
On Thursday, 10 February 2022 at 10:59:17 UTC, tastyminerals wrote: Not sure if the `update` method got changed but I am having trouble with understanding it now. I assumed it would work as easy as in Python:) Just do `mydic.update(dic)` or `mydic["key"].update(anotherDic)`. The docs have the

Re: Filling an array at compile time

2022-02-09 Thread bauss via Digitalmars-d-learn
On Wednesday, 9 February 2022 at 16:37:22 UTC, Ali Çehreli wrote: On 2/9/22 01:07, bauss wrote: > It will not run at compile-time because csvText is a runtime variable. > It should be enum to be accessible at compile-time. Yes. For the sake of completeness, any expression needed at compile

Re: how to handle very large array?

2022-02-09 Thread bauss via Digitalmars-d-learn
On Wednesday, 9 February 2022 at 10:03:21 UTC, MichaelBi wrote: day6 of the advent of code 2021 needs to handle an array of 10^12 length, or even bigger... plus change elements and append elements. normal implementation such as length, appender and ref element etc, seems cannot handle that big

Re: Filling an array at compile time

2022-02-09 Thread bauss via Digitalmars-d-learn
On Wednesday, 9 February 2022 at 10:01:15 UTC, Anonymouse wrote: On Wednesday, 9 February 2022 at 08:12:52 UTC, Vindex wrote: Will the loop (foreach) run at compile time? How can I make it work at compile time? ``` import std.csv, std.stdio; alias Record = Tuple!(string, string, string);

Re: Filling an array at compile time

2022-02-09 Thread bauss via Digitalmars-d-learn
On Wednesday, 9 February 2022 at 08:12:52 UTC, Vindex wrote: Will the loop (foreach) run at compile time? How can I make it work at compile time? ``` import std.csv, std.stdio; alias Record = Tuple!(string, string, string); immutable string[][] table; shared static this() { string

Re: ldc executable crashes with this code

2022-02-07 Thread bauss via Digitalmars-d-learn
On Saturday, 5 February 2022 at 03:02:37 UTC, forkit wrote: On Friday, 4 February 2022 at 15:58:19 UTC, Stanislav Blinov wrote: .. ... As others have already stated, casting immutability away is something that has to be supported, e.g. to interface with const-agnostic APIs. `@safe` requires

Re: iteration over directories is unsafe

2022-02-07 Thread bauss via Digitalmars-d-learn
On Saturday, 5 February 2022 at 23:26:21 UTC, forkit wrote: It is not possible to do a simple iteration over directories in @safe mode. Really? I have to resort to unsafe?? // module test; @safe: // nope. no can do. import std; void main() { auto dFiles = dirEntries("",

Re: automate tuple creation

2022-01-20 Thread bauss via Digitalmars-d-learn
On Thursday, 20 January 2022 at 04:00:59 UTC, forkit wrote: On Thursday, 20 January 2022 at 00:30:44 UTC, H. S. Teoh wrote: Do the id's have to be unique? yep... Don't make them random then, but use an incrementor. If you can have ids that aren't integers then you could use uuids too.

Re: non-constant expression ["foo":5, "bar":10, "baz":2000]

2022-01-06 Thread bauss via Digitalmars-d-learn
On Thursday, 6 January 2022 at 16:01:40 UTC, HuskyNator wrote: On Thursday, 6 January 2022 at 13:33:24 UTC, bauss wrote: While not the exact same, there's a small work around here that can help in some cases: ```d immutable long[string] aa; shared static this() { aa = [ "foo": 5,

Re: non-constant expression ["foo":5, "bar":10, "baz":2000]

2022-01-06 Thread bauss via Digitalmars-d-learn
On Thursday, 6 January 2022 at 12:04:12 UTC, HuskyNator wrote: On Monday, 28 November 2016 at 14:41:44 UTC, Era Scarecrow wrote: On Monday, 28 November 2016 at 09:06:34 UTC, Paolo Invernizzi wrote: The point is that I was trying to avoid some cycle between modules, detected by 2.072. This bug

Re: Thread exits immediately with no reason.

2021-12-20 Thread bauss via Digitalmars-d-learn
On Tuesday, 21 December 2021 at 01:13:10 UTC, Ali Çehreli wrote: Note: nothrow means "does not throw Exception". Errors can still be thrown. Ali Which sort of makes sense since they're in theory "unrecoverable", but the name is sort of misleading because of this minor detail. It should

Re: Is it possible to do this with a template?

2021-12-17 Thread bauss via Digitalmars-d-learn
On Friday, 17 December 2021 at 08:59:19 UTC, rempas wrote: On Friday, 17 December 2021 at 08:44:39 UTC, Mitacha wrote: It isn't really about limitation of templates. You're trying to use mixin template and it's main purpose is to inject declarations. If you want to replace `is expression`

Re: How to define property type to Array!struct?

2021-12-15 Thread bauss via Digitalmars-d-learn
On Wednesday, 15 December 2021 at 11:36:41 UTC, Manfred Nowak wrote: On Tuesday, 14 December 2021 at 08:28:01 UTC, WebFreak001 wrote: [...] Alternatively, remove the template `()` from your `struct Header` What is the semantic sense of a template having no parameters? Although the

Re: How to loop through characters of a string in D language?

2021-12-12 Thread bauss via Digitalmars-d-learn
On Monday, 13 December 2021 at 05:46:06 UTC, forkit wrote: On Saturday, 11 December 2021 at 09:25:37 UTC, Ola Fosheim Grøstad wrote: ```putchar(…)``` is too slow! On planet Mars maybe, but here on earth, my computer can do about 4 billion ticks per second, and my entire program (using

Re: How to loop through characters of a string in D language?

2021-12-08 Thread bauss via Digitalmars-d-learn
On Wednesday, 8 December 2021 at 11:23:45 UTC, BoQsc wrote: Let's say I want to skip characters and build a new string. The string example to loop/iterate: ``` import std.stdio; void main() { string a="abc;def;ab"; } ``` The character I want to skip: `;` Expected result: ``` abcdefab

Re: How to deploy single exe application (?)

2021-11-30 Thread bauss via Digitalmars-d-learn
On Monday, 29 November 2021 at 14:58:07 UTC, Willem wrote: Thanks again for all the responses. For now -- I am simply adding the DLL to the EXE and writing it out to the working directory. Not elegant - but it does work. If you intend to distribute it then becareful with this as it

Re: what i don't like about dub

2021-11-23 Thread bauss via Digitalmars-d-learn
On Tuesday, 23 November 2021 at 10:19:29 UTC, Tejas wrote: On Tuesday, 23 November 2021 at 07:06:17 UTC, bauss wrote: On Tuesday, 23 November 2021 at 01:19:44 UTC, Alain De Vos wrote: [...] Well, it's not always possible to check such things without heavy performance cost. It can take a

Re: what i don't like about dub

2021-11-22 Thread bauss via Digitalmars-d-learn
On Tuesday, 23 November 2021 at 01:19:44 UTC, Alain De Vos wrote: What i don't like about dub is that is does not check which software is installed on the host. Currentlu tck86 is installed on the host including header files & shared libraries. But dub says let me just download my own personal

Re: Null pointer in __vptr

2021-11-22 Thread bauss via Digitalmars-d-learn
On Friday, 19 November 2021 at 20:27:11 UTC, frame wrote: On Friday, 19 November 2021 at 18:14:03 UTC, Adam D Ruppe wrote: I've gotten that before as a result of a compiler bug... I had an abstract method that wasn't implemented but the compile time error got swallowed by a bug and thus the

Re: Exceptions names list

2021-11-16 Thread bauss via Digitalmars-d-learn
On Monday, 15 November 2021 at 22:44:35 UTC, Ali Çehreli wrote: On 11/15/21 2:28 PM, pascal111 wrote: > I want to know where the list of exceptions names that "throw" statement > uses. Such a list is not very useful. Normally all we need is Exception and occasionally one or two other specific

Re: What is D's "__debugbreak()" equivalent?

2021-10-29 Thread bauss via Digitalmars-d-learn
On Friday, 29 October 2021 at 11:36:13 UTC, Adam D Ruppe wrote: On Friday, 29 October 2021 at 09:32:07 UTC, bauss wrote: } else version(D_InlineAsm_X86_64) { just fyi but `int 3;` works just as well in 32 bit as 64 Yeah, that's why I noted that there's also D_InlineAsm_X86 but I

Re: What is D's "__debugbreak()" equivalent?

2021-10-29 Thread bauss via Digitalmars-d-learn
On Thursday, 28 October 2021 at 09:54:44 UTC, Dennis wrote: On Wednesday, 27 October 2021 at 16:54:49 UTC, Simon wrote: What is the equivalent in D? With LDC, you have: ```D import ldc.intrinsics: llvm_debugtrap; ``` Combining that with previous answers, you can make something like this:

Re: Error: Could not open 'libcmt.lib'

2021-10-27 Thread bauss via Digitalmars-d-learn
On Monday, 25 October 2021 at 14:43:06 UTC, Willem wrote: Just starting out new with D. Up until now I have been using Python and a bit of OCaml. Error when linking: "lld-link: error: could not open 'libcmt.lib': no such file or directory" What I did: I installed the complete D setup in

Re: TimeoutException for connecting to MySQL using a hunt-entity.

2021-10-27 Thread bauss via Digitalmars-d-learn
On Monday, 25 October 2021 at 12:54:32 UTC, greenbyte wrote: On Monday, 25 October 2021 at 07:45:26 UTC, Imperatorn wrote: On Friday, 22 October 2021 at 11:42:34 UTC, greenbyte wrote: Hi, all! I use the hunt-entity library to work with MySQL. I get the hunt.Exceptions.TimeoutException:

Re: std.zip expand: memory allocation failed

2021-10-27 Thread bauss via Digitalmars-d-learn
On Tuesday, 26 October 2021 at 13:43:36 UTC, Steven Schveighoffer wrote: On 10/26/21 2:32 AM, bauss wrote: On Monday, 25 October 2021 at 22:38:38 UTC, Imperatorn wrote: On Monday, 25 October 2021 at 20:50:40 UTC, Steven Schveighoffer wrote: On 10/24/21 8:00 AM, Selim Ozel wrote: It turns out

Re: std.zip expand: memory allocation failed

2021-10-26 Thread bauss via Digitalmars-d-learn
On Monday, 25 October 2021 at 22:38:38 UTC, Imperatorn wrote: On Monday, 25 October 2021 at 20:50:40 UTC, Steven Schveighoffer wrote: On 10/24/21 8:00 AM, Selim Ozel wrote: It turns out my computer was literally running out of memory as the file was getting unzipped. For some reason  to

Re: Why do we have Dmain?

2021-10-25 Thread bauss via Digitalmars-d-learn
On Monday, 25 October 2021 at 07:49:44 UTC, user1234 wrote: so with the D main you're directly in the the D "domain". In theory from that point, you don't need to ever use `strlen` for example. Not just that, but you shouldn't use it at all, rather you can't use it! You might be able to

Re: TimeoutException for connecting to MySQL using a hunt-entity.

2021-10-25 Thread bauss via Digitalmars-d-learn
On Sunday, 24 October 2021 at 20:58:22 UTC, greenbyte wrote: On Friday, 22 October 2021 at 11:51:03 UTC, WebFreak001 wrote: On Friday, 22 October 2021 at 11:42:34 UTC, greenbyte wrote: Hi, all! I use the hunt-entity library to work with MySQL. I get the hunt.Exceptions.TimeoutException:

Re: __traits(compiles) is true with warnings as errors

2021-10-14 Thread bauss via Digitalmars-d-learn
On Thursday, 14 October 2021 at 05:41:01 UTC, Tejas wrote: On Wednesday, 13 October 2021 at 17:58:23 UTC, Jonathan Levi wrote: When dmd is passed the "-w" tag, it "treats warnings as errors" but not with the "__traits(compiles)" expression. Is this the intended action? This code should

Re: Linker error

2021-10-12 Thread bauss via Digitalmars-d-learn
On Tuesday, 12 October 2021 at 00:01:25 UTC, jfondren wrote: On Monday, 11 October 2021 at 23:43:17 UTC, Ruby The Roobster wrote: package mixin template move__() { pragma(inline) package void mv(Point moveby, ref Skeleton tomove) { foreach(i;tomove.faces) {

Re: How to "stringnify"?

2021-10-11 Thread bauss via Digitalmars-d-learn
On Sunday, 10 October 2021 at 09:51:27 UTC, rempas wrote: On Sunday, 10 October 2021 at 08:48:21 UTC, Imperatorn wrote: For simple stuff you have .stringof Thanks! Just remember .stringof is not "literal" as in there are certain expression that won't return exactly what you're trying to

Re: Mutually recursive template expansion

2021-10-04 Thread bauss via Digitalmars-d-learn
On Friday, 1 October 2021 at 14:26:39 UTC, jfondren wrote: On Friday, 1 October 2021 at 14:03:06 UTC, Stephen wrote: This code should work should mutual recursion be supported. It still wouldn't work, because structs are value types and it's impossible to say how large either struct is:

Re: Why sometimes stacktraces are printed and sometimes not?

2021-09-30 Thread bauss via Digitalmars-d-learn
On Wednesday, 29 September 2021 at 12:15:30 UTC, Steven Schveighoffer wrote: On 9/29/21 6:57 AM, JN wrote: What makes the difference on whether a crash stacktrace gets printed or not? Sometimes I get a nice clean stacktrace with line numbers, sometimes all I get is "segmentation fault error

Re: What is the meaning of @future ?

2021-09-17 Thread bauss via Digitalmars-d-learn
On Thursday, 16 September 2021 at 20:53:34 UTC, Elmar wrote: Hello D community. I was browsing the `__traits` keywords and I found `isFuture` whose descriptions says something about `@future`-annotated variables. [link](https://dlang.org/spec/traits.html#isFuture) I didn't find anything

Re: Is this a compiler aliasing bug?

2021-09-17 Thread bauss via Digitalmars-d-learn
On Friday, 17 September 2021 at 09:44:53 UTC, Chris Katko wrote: I'm debugging some code I wrote back in 2017 and a bounding box collision detection kept giving spurious answers till I resorted to assuming nothing and dumped every variable and alias. I kept getting results like it was

Re: GC seems to crash my C-code function

2021-09-16 Thread bauss via Digitalmars-d-learn
On Thursday, 16 September 2021 at 11:35:27 UTC, frame wrote: On Thursday, 16 September 2021 at 11:11:56 UTC, bauss wrote: On Thursday, 16 September 2021 at 11:06:04 UTC, frame wrote: On Thursday, 16 September 2021 at 10:48:19 UTC, bauss wrote: Use toStringz and not .ptr. Or append \0 to

Re: GC seems to crash my C-code function

2021-09-16 Thread bauss via Digitalmars-d-learn
On Thursday, 16 September 2021 at 11:06:04 UTC, frame wrote: On Thursday, 16 September 2021 at 10:48:19 UTC, bauss wrote: Use toStringz and not .ptr. Or append \0 to your string. Stupid me should really know that already, thanks =) Of course I have dup'ed the \0 from the string away...

Re: GC seems to crash my C-code function

2021-09-16 Thread bauss via Digitalmars-d-learn
On Thursday, 16 September 2021 at 10:48:19 UTC, bauss wrote: On Thursday, 16 September 2021 at 10:28:37 UTC, frame wrote: I have C-code translated in D that acts sometimes incorrect if the GC has made some collect. I would like to know why. - Code runs correct if the GC collections are off -

Re: GC seems to crash my C-code function

2021-09-16 Thread bauss via Digitalmars-d-learn
On Thursday, 16 September 2021 at 10:28:37 UTC, frame wrote: I have C-code translated in D that acts sometimes incorrect if the GC has made some collect. I would like to know why. - Code runs correct if the GC collections are off - There are no allocations within the C-translated-code except

Re: GDC - program runs in one thread, DMD - in 4 threads, why?

2021-09-10 Thread bauss via Digitalmars-d-learn
On Friday, 10 September 2021 at 12:46:36 UTC, eugene wrote: On Friday, 10 September 2021 at 12:10:58 UTC, Adam D Ruppe wrote: btw why do the threads cause you trouble? Well... probably it is subjective thing - just do not 'like' when a program is doing something that is not explicitly in it's

Re: GDC - program runs in one thread, DMD - in 4 threads, why?

2021-09-10 Thread bauss via Digitalmars-d-learn
On Friday, 10 September 2021 at 10:39:48 UTC, Basile B. wrote: On Friday, 10 September 2021 at 09:27:49 UTC, eugene wrote: Here is test program (which is using DList aggressively) [...] Can this (really unwanted) behavior be disabled in DMD? I do not want to have multiple threads, a program

Re: Ali's Book - Programming in D

2021-09-10 Thread bauss via Digitalmars-d-learn
On Friday, 10 September 2021 at 10:46:25 UTC, Ron Tarrant wrote: I guess this is mainly a question for Ali, but if anyone else knows the answer, please jump in... If I were to buy a paperback copy of "Programming in D: Tutorial & Reference" from Amazon (this link:

Re: Looking to get typeof parseXML return value

2021-09-07 Thread bauss via Digitalmars-d-learn
On Tuesday, 7 September 2021 at 08:27:33 UTC, JN wrote: On Tuesday, 7 September 2021 at 04:13:08 UTC, Chris Piker wrote: Like almost all new users to D I'm tripping over how to save and pass around variables since nothing has an understandable type anymore and you can't use "auto" for *class

Re: Module import incompatibility

2021-08-31 Thread bauss via Digitalmars-d-learn
On Tuesday, 31 August 2021 at 12:26:28 UTC, frame wrote: I'm sure it was asked before but can't find the thread: How to deal best with an older library that uses the same class name as module name? I get a lot of `Error: module ABC from file ...ABC.d must be imported with 'import ABC'` Do

Re: vibe.d: is it possible to use bare HTML with the functionalty of DIET templates ?

2021-08-31 Thread bauss via Digitalmars-d-learn
On Tuesday, 31 August 2021 at 00:09:14 UTC, someone wrote: Regarding vibe.d I think I'll give it a try (maybe placing it behind nginx at first) since I do really got a good first-impression ... kudos to the developers/maintainers :) I like the idea of having D at my disposal within a web

Re: vibe.d community/forum/whatever ?

2021-08-30 Thread bauss via Digitalmars-d-learn
On Monday, 30 August 2021 at 02:39:06 UTC, someone wrote: https://forum.rejectedsoftware.com/groups/rejectedsoftware.vibed/ I've been reading vibe.d tour and some documentation today to get some first impressions. https://vibed.org/community pointed to the link above ... but it seems it is

Re: foreach() behavior on ranges

2021-08-25 Thread bauss via Digitalmars-d-learn
On Tuesday, 24 August 2021 at 19:06:44 UTC, Alexandru Ermicioi wrote: On Tuesday, 24 August 2021 at 09:15:23 UTC, bauss wrote: A range should be a struct always and thus its state is copied when the foreach loop is created. Actually the range contracts don't mention that it needs to be a

Re: foreach() behavior on ranges

2021-08-24 Thread bauss via Digitalmars-d-learn
On Tuesday, 24 August 2021 at 08:36:18 UTC, frame wrote: Consider a simple input range that can be iterated with empty(), front() and popFront(). That is comfortable to use with foreach() but what if the foreach loop will be cancelled? If a range isn't depleted yet and continued it will supply

Re: Associative Array with double[][]

2021-07-22 Thread bauss via Digitalmars-d-learn
On Thursday, 22 July 2021 at 03:13:14 UTC, seany wrote: I have a perimeter of a shape, given by a `double [][]` . I want to keep the lengths of various diagonals in another associative array. So, /// define some associative array to keep track of diagonals here.. auto perimeter =

Re: How to Fix Weird Build Failure with "-release" but OK with "-debug"?

2021-07-21 Thread bauss via Digitalmars-d-learn
On Wednesday, 21 July 2021 at 03:25:03 UTC, apz28 wrote: VisualD project - Any hint to work around DMD version: DMD32 D Compiler v2.096.0-rc.1-dirty Copyright (C) 1999-2021 by The D Language Foundation, All Rights Reserved written by Walter Bright Failed Build Command line: dmd -release

Re: Method definition

2021-07-21 Thread bauss via Digitalmars-d-learn
On Wednesday, 21 July 2021 at 12:08:21 UTC, Tim Gunesh wrote: Is it possible to define methods outside the class in C ++ style? Something like this: ```d class Parent{ void Print(); } void Parent.Print(){ writeln("Hello, D!"); } ``` No and it doesn't make much sense to do so. The

Re: Can static variables in methods be local for each object?

2021-07-21 Thread bauss via Digitalmars-d-learn
On Tuesday, 20 July 2021 at 15:59:30 UTC, Dukc wrote: On Tuesday, 20 July 2021 at 09:24:07 UTC, Mark Lagodych wrote: Is there a way to make myvar local to each instance of `X` without making it a variable of `X`? Just curious. Yes. ```d import std.stdio; class X { int x(int param) {

Re: Can static variables in methods be local for each object?

2021-07-20 Thread bauss via Digitalmars-d-learn
On Tuesday, 20 July 2021 at 09:24:07 UTC, Mark Lagodych wrote: Let's say I have this code: ```d import std.stdio; class X { int x(int param) { static int myvar = 1234; if (param == 0) return myvar; else { myvar = param; return myvar; } } } void main() { X

Re: float price; if (price == float.nan) { // initialized } else { // uninitialized } ... valid ?

2021-07-08 Thread bauss via Digitalmars-d-learn
On Wednesday, 30 June 2021 at 16:41:40 UTC, someone wrote: On Wednesday, 30 June 2021 at 16:24:38 UTC, Andre Pany wrote: Side note: in case you want to work with money, you may consider using a specific data type like https://code.dlang.org/packages/money instead of float/double. Yes, I've

Re: float price; if (price == float.nan) { // initialized } else { // uninitialized } ... valid ?

2021-07-08 Thread bauss via Digitalmars-d-learn
On Wednesday, 30 June 2021 at 16:19:35 UTC, someone wrote: On Wednesday, 30 June 2021 at 10:38:05 UTC, jmh530 wrote: You've never given something away for free? ... more often than usual LoL Now, seriously, something for free has not a price = 0, it has NO price, that's what null is for;

vibe.d and video files?

2020-09-17 Thread bauss via Digitalmars-d-learn
Does vibe.d not work properly with ex. mp4 files? I have a consistent issues that it will only play part of video files in the browser. As if it won't "stream" the rest of the video. Is that a problem with vibe.d or is it some configuration that needs to be enabled?

Re: vibe.d and my first web service

2020-07-19 Thread bauss via Digitalmars-d-learn
On Saturday, 18 July 2020 at 17:23:06 UTC, Mr. Backup wrote: On Saturday, 18 July 2020 at 12:16:09 UTC, Andre Pany wrote: On Saturday, 18 July 2020 at 09:10:04 UTC, Mr. Backup wrote: [...] I assume you are using vibe.d 0.8.4 or older. Please check whether adding this to dub.json solves your

Re: Vibe.d and NodeJs with Express

2020-07-14 Thread bauss via Digitalmars-d-learn
On Sunday, 12 July 2020 at 19:16:32 UTC, aberba wrote: 3) packages, now it might be better though. But I've always felt that there's not a lot of people using D for complete web dev projects... I'm one of the few but then again I don't use a lot of external packages either other than what

Re: constructing labels for static foreach inside switch inside foreach

2020-07-07 Thread bauss via Digitalmars-d-learn
On Wednesday, 8 July 2020 at 02:06:01 UTC, Steven Schveighoffer wrote: OK, so I have a situation where I'm foreaching over a compile-time list of types. Inside the loop, I'm using a second loop over a set of input. Inside that loop, I'm using a switch on the input, and inside the switch, I'm

Re: I want Sublime 3 D auto import !

2020-06-03 Thread bauss via Digitalmars-d-learn
On Wednesday, 3 June 2020 at 11:54:57 UTC, Виталий Фадеев wrote: On Tuesday, 2 June 2020 at 20:08:09 UTC, bauss wrote: What happens if you have the same symbol in multiple modules? Ex. two libraries that implement symbols with same name. First module will inserted. Is there a way to be

Re: I want Sublime 3 D auto import !

2020-06-02 Thread bauss via Digitalmars-d-learn
On Tuesday, 2 June 2020 at 06:00:10 UTC, Виталий Фадеев wrote: On Monday, 1 June 2020 at 18:55:03 UTC, Paul Backus wrote: On Monday, 1 June 2020 at 16:18:44 UTC, Виталий Фадеев wrote: I do it! https://github.com/vitalfadeev/SublimeDlangAutoImport What happens if you have the same symbol in

Re: How to get the pointer of "this" ?

2020-05-26 Thread bauss via Digitalmars-d-learn
On Tuesday, 26 May 2020 at 12:08:29 UTC, Johannes Loher wrote: On Tuesday, 26 May 2020 at 11:44:58 UTC, Vinod K Chandran wrote: On Monday, 25 May 2020 at 16:39:30 UTC, Mike Parker wrote: On Monday, 25 May 2020 at 08:39:23 UTC, John Burton wrote: I believe that in D *this* is a reference to

Re: How to get the pointer of "this" ?

2020-05-25 Thread bauss via Digitalmars-d-learn
On Monday, 25 May 2020 at 17:14:13 UTC, Vinod K Chandran wrote: On Monday, 25 May 2020 at 16:54:11 UTC, Mike Parker wrote: On Monday, 25 May 2020 at 16:26:31 UTC, Vinod K Chandran wrote: [...] The error has nothing to do with taking a pointer to `this`. It's suggesting that somewhere in

Re: How to get the pointer of "this" ?

2020-05-24 Thread bauss via Digitalmars-d-learn
On Sunday, 24 May 2020 at 17:05:16 UTC, Vinod K Chandran wrote: Hi all, I have a class like this. class Button : Control { ... HWND createButton(){ ... SetWindowSubclass(this.mHandle, SUBCLASSPROC(), UINT_PTR(subClsID), cast(DWORD_PTR) this); } } But

Re: Variable "i" can not be read at compile time

2020-05-24 Thread bauss via Digitalmars-d-learn
On Sunday, 24 May 2020 at 17:13:23 UTC, data pulverizer wrote: On Sunday, 24 May 2020 at 16:57:54 UTC, ag0aep6g wrote: On 24.05.20 18:34, data pulverizer wrote: Since `kernel` is a `Tuple`, you can only access it with compile-time constant indices. But your loop variable `i` is not a

Re: Using Vibe.d for not HTTP

2020-05-24 Thread bauss via Digitalmars-d-learn
On Sunday, 24 May 2020 at 08:10:33 UTC, Russel Winder wrote: Hi, Clearly Vibe.d is mostly for people doing HTTP and HTTPS stuff. Yet it claims to be able to support TCP and UDP working with other protocols. However, all the serious examples are HTTP/HTTPS related. All the TCP and UDP

Re: Distinguish between a null array and an empty array

2020-05-24 Thread bauss via Digitalmars-d-learn
On Sunday, 24 May 2020 at 12:26:42 UTC, ag0aep6g wrote: On 24.05.20 14:12, bauss wrote: Is there a way to do that? Since the following are both true: int[] a = null; int[] b = []; assert(a is null); assert(!a.length); assert(b is null); assert(!b.length); What I would like is to tell that

  1   2   3   4   5   >