Re: Beerconf February 2021

2021-02-26 Thread Adam D. Ruppe via Digitalmars-d-announce
On Friday, 26 February 2021 at 18:06:45 UTC, Ali Çehreli wrote: Whose tomorrow? :) For some reason I need exact times for this. Is it all weekend hours anywhere on the world or specific UTC times? The way it works is usually one person gets on at some random point typically around the

Re: Compile-Time Function Parameters That Aren't Types?

2021-02-23 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 24 February 2021 at 03:52:57 UTC, Kyle Ingraham wrote: The part that got my attention was `bool isBGR`. I was under the impression that compile-time or template parameters were only for types. No, you can pass almost anything to them.

Re: ldc on a raspberry pi 3 running freebsd

2021-02-23 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 23 February 2021 at 14:56:45 UTC, Decabytes wrote: I installed it with "pkg install ldc", but embarrassingly I'm not actually sure where the compiler is. ldc isn't a recognized action on the command line It is often called `ldc2` so give that a try. btw I run gdc on my raspberry

Re: Foo Foo = new Foo();

2021-02-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 21 February 2021 at 21:03:27 UTC, Jack wrote: Why doesn't this compiles? class Baa { Foo Foo = new Foo(); } Local variables inside functions are a little bit special because everything happens in sequence. This is a declaration, where there is a new namespace, but order

Re: Foo Foo = new Foo();

2021-02-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 21 February 2021 at 18:15:22 UTC, JN wrote: I guess D is smart enough to figure out which is a type and which is a variable. C++ gets confused in similar situation. Well it isn't about type vs variable (except for in this exact declaration), it is just one is defined at top level

Re: I learned something new in D this week! (anonymous class rundown)

2021-02-19 Thread Adam D. Ruppe via Digitalmars-d-announce
On Friday, 19 February 2021 at 17:41:51 UTC, Patrick Schluter wrote: DWT users knew about anonymous classes as they are used a lot there. Of course as SWT is a Java based library, D had to had the features to ease the porting. Aye, my understanding is actually they were added to do

Re: I learned something new in D this week! (anonymous class rundown)

2021-02-18 Thread Adam D. Ruppe via Digitalmars-d-announce
On Thursday, 18 February 2021 at 22:37:06 UTC, superbomba wrote: Once I start reading, I can't stop! :) Better be careful, there's about 250 entries now so you could waste away trying to read it all! (About 145 in twid's first iteration and now about 115 in the second iteration. Of course

Re: Strings and Slices

2021-02-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 18 February 2021 at 20:47:33 UTC, Mike Brown wrote: Is slices comparable to a string_view? My c++ is rusty af but yes I think so. A d slice is `struct slice { size_t length; T* ptr; }` so when in doubt just think back to what that does. string lex_identifier(ref string input)

Re: I learned something new in D this week! (anonymous class rundown)

2021-02-18 Thread Adam D. Ruppe via Digitalmars-d-announce
On Thursday, 18 February 2021 at 16:54:31 UTC, Ritter wrote: Somebody from russian D's Telegram channel translates your article into Russian. Maybe, it can be usefull Nice!

Re: I learned something new in D this week! (anonymous class rundown)

2021-02-18 Thread Adam D. Ruppe via Digitalmars-d-announce
On Thursday, 18 February 2021 at 07:28:27 UTC, Ferhat Kurtulmuş wrote: I came across anonymous classes by reading your minigui codes, such as [1] some time ago. I did not read anything about them except your sources. Good reading, thanks. Yeah, I sometimes see them on lists of features to be

I learned something new in D this week! (anonymous class rundown)

2021-02-17 Thread Adam D. Ruppe via Digitalmars-d-announce
Many of you know I've been around D for a long time now and picked up a lot of random tricks over the years, so it isn't every day I learn about a new old feature in the language's basic syntax. Would you like to know more? http://dpldocs.info/this-week-in-d/Blog.Posted_2021_02_15.html I

Re: null and initialized string comparisons

2021-02-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 17 February 2021 at 20:48:22 UTC, Martin wrote: is this how it supposed to be? (https://run.dlang.io/is/7B4irm) == compares contents. Both null and "" have empty contents and are interchangable for operators that work on contents. The assert just looks at the pointer, not

Re: Web crawler/scraping

2021-02-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 17 February 2021 at 12:12:56 UTC, Carlos Cabral wrote: I'm trying to collect some json data from a website/admin panel automatically, which is behind a login form. Does the website need javascript? If not, my dom.d may be able to help. It can download some HTML, parse it, fill

Re: how to make this function nothrow?

2021-02-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 15 February 2021 at 21:04:50 UTC, Jack wrote: obviously, insert a try-catch() within catch() is a circular dependence and doesn't solve the problem either (even if it, I think it would be quite ugly) well that's prolly the way to do it, just catch Exception and like assert(0) if

Re: Confusing with chunkBy

2021-02-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 15 February 2021 at 20:51:53 UTC, Maksim wrote: Thanks for answer, Adam. I lost the key word "adjacent". yeah, you aren't the only one, I think the docs should call it more more illustratively with an example or something too. The reason why it is designed this way is just to get

Re: Confusing with chunkBy

2021-02-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 15 February 2021 at 19:57:39 UTC, Maksim wrote: Hello. Why The docs say it: "chunks an input range into subranges of equivalent adjacent elements." The key word there is "adjacent". and the docs follow up "Elements in the subranges will always appear in the same order they

Re: How can I clean array and prevent further reallocation if there's enough space already?

2021-02-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 7 February 2021 at 21:40:12 UTC, Jack wrote: I think it would be fine except it assumes the number of items of the array to doesn't grow, it rather overwritten new elements from docs: "Use this only when it is certain there are no elements in use beyond the array in the memory

Re: How can I clean array and prevent further reallocation if there's enough space already?

2021-02-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 7 February 2021 at 21:31:11 UTC, Jack wrote: assumeSafeAppend() wouldn't work in this case because I don't know the number of items that is going to be added to the array. I don't think that matters. assumeSafeAppend seems appropriate for your need.

Re: Tuple or struct as return type?

2021-02-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 6 February 2021 at 18:02:46 UTC, Martin wrote: Why/when i should prefer Tuple as a return type over returning a struct (or even string[2] in this case)? A Tuple is just a struct declared inlined. I personally use struct every single time - structs can be separately documented

Re: Can someone explain this?

2021-02-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 6 February 2021 at 14:39:38 UTC, Jeff wrote: Okay, the above works. But, I'm not sure why? Phobos's enum conversion always looks at the identifier, whereas the rest of the language looks at the value. Remember phobos' writeln forwards to the rest of its conversions just like

Re: unittest compiles w/o error though module file is not named after the module

2021-02-06 Thread Adam D. Ruppe via Digitalmars-d-learn
Module names and file names are completely independent on the language level. You can have a file `whatever.d` with `module foo.bar.totally.different;` and `import foo.bar.totally.different` and it all works as long as you add the whatever.d to the build. The only reason people recommend

Re: Using the Standard Library with C++ Interop

2021-02-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 5 February 2021 at 21:04:00 UTC, wolfiesnotfine wrote: however sse() from core.cpuid is incorrectly reporting as false. The function properly returns true if it's not called from C++ but instead a D main function. That makes me think it is a static constructor, and indeed there is

Re: What is the difference between static linking with .a and .so libphobos?

2021-02-02 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 2 February 2021 at 22:39:40 UTC, WhatMeWorry wrote: Don't we want to Dynamically link with shared libphobos2.so? Yeah, I imagine what they meant was statically binding to the dynamic link library as opposed to loading certain procedures at runtime one by one. With the .a file,

Re: How can I stop D from dropping decimals in strings

2021-02-02 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 2 February 2021 at 22:27:53 UTC, Tim wrote: I have to serialize an array like [0.0, 0.0, 0.0] to a Json object. During this process, the serializer creates a string of the array, but it creates "[0, 0, 0]", dropping the decimal. How can I stop this? This depends on the library

Re: Quick question

2021-02-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 1 February 2021 at 16:19:13 UTC, Ruby The Roobster wrote: Thanks. However for a char[], .sizeof = .length because a char is one byte. Nope, char[].sizeof is a platform-specific constant not related to the length at all. void main() { import std.stdio; char[] a =

Re: Quick question

2021-01-29 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 30 January 2021 at 00:58:09 UTC, Ruby The Roobster wrote: I have question here. Is there a difference between .sizeof and .length(of a char[])? for future reference if someone stumbles on this, .sizeof is the static size of the reference, .length is the actual length of the

Re: Why does calling readln() more than once not work

2021-01-28 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 28 January 2021 at 19:25:52 UTC, Ruby The Roobster wrote: readf(" %d",); This leaves the \n at the end. A next readf thanks to the leading space would ignore that \n and keep going, but a readln stops at the first \n it sees, even if it is a leftover item in the buffer

Re: Conversion error.

2021-01-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 28 January 2021 at 01:01:36 UTC, Ruby The Roobster wrote: readf("%d",x); This is why I hate readf, it is sensitive to litte things. If you put a space in that string I think it will fix it. What happens here is it reads the float, then leaves the buffer at the \n from when

Re: Why filling AA in shared library freezes execution?

2021-01-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 27 January 2021 at 15:25:17 UTC, H. S. Teoh wrote: I'm surprised this stuff hasn't been fixed yet, considering Walter (mostly?) works on Windows. Has he never run into these issues before? It had a dconf talk spell it all out. But it can be difficult to reproduce the nasty

Re: Why filling AA in shared library freezes execution?

2021-01-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 27 January 2021 at 14:36:16 UTC, Adam D. Ruppe wrote: (btw as for me fixing it myself oh edit, I should point out it also requires some degree of language change to match what Microsoft's C++ does. They do dllimport and dllexport annotations to help the compiler generate

Re: Why filling AA in shared library freezes execution?

2021-01-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 27 January 2021 at 13:39:32 UTC, SealabJaster wrote: The biggest one for me, is that RTTI isn't "shared" across boundaries. Yeah, that's a big one. Exception handling tables are also not properly merged leading to random behavior even if you do manage to catch the exception (I

Re: Why filling AA in shared library freezes execution?

2021-01-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 25 January 2021 at 21:48:10 UTC, Vitalii wrote: Q: Why filling assoc.array in shared library freeze execution? D exes loading D dlls are very broken on Windows. You can kinda make it work but there's a lot of bad design and showstopper bugs. That's the sad reality of it. I'd

Re: How do I overload += operator?

2021-01-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 25 January 2021 at 17:09:22 UTC, Jack wrote: auto ref opAssign(string op, T)(T value) try opOpAssign instead opAssign is for = opOpAssign is for +=, -=, etc. It might be some variation but I think it works if you just rename it.

Re: real beginner question about D's web site?

2021-01-24 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 24 January 2021 at 20:05:47 UTC, WhatMeWorry wrote: mentions the $ signs, as well as the $1 and $3. See point 4 here: https://dlang.org/spec/ddoc.html#macros $(THING ...) is a macro invocation. Inside the macro definition, $0 is the full text represented by "..." here. Then $1

Re: Issue with socket recieve

2021-01-20 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 21 January 2021 at 03:24:13 UTC, Tim wrote: No, I don't. It should be all garbage collected right? Yeah, but that's where the problem comes. Note that by destructor, I mean *any* function in your code called `~this() {}`. If there are any and they call a memory allocation

Re: Issue with socket recieve

2021-01-20 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 20 January 2021 at 21:31:54 UTC, Tim wrote: Unable to open 'recv.c': Unable to read file '/build/glibc-ZN95T4/glibc-2.31/sysdeps/unix/sysv/linux/recv.c' (Error: Unable to resolve non-existing file '/build/glibc-ZN95T4/glibc-2.31/sysdeps/unix/sysv/linux/recv.c'). [snip] generate

Re: Exit code -4

2021-01-20 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 21 January 2021 at 00:37:19 UTC, Tim wrote: Hi all, From time to time my program crashes with exit code -4. I can't seem to find much on the code. Does anyone know what this means and how to debug the issue? Unix signal #4 is illegal instruction (negative returns usually mean

Re: Generating documentation help

2021-01-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 20 January 2021 at 01:00:32 UTC, Tim wrote: But if I deleted index.html then reran the doc gen, it worked just fine. Looks like index.html is not being updated oh yeah i forgot i did that cuz I so often build individual files and it deleting the index annoyed me

Re: Generating documentation help

2021-01-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 20 January 2021 at 00:16:51 UTC, Tim wrote: They are defined "module simulator" and "module analyzer". I also have "module math" etc. that are added to the index That's weird... There are a bunch of command line args to adrdox that might help like --document-undocumented

Re: Generating documentation help

2021-01-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 20 January 2021 at 00:06:35 UTC, Tim wrote: Yeah, they have both. They also contain the main entrypoint What are the module names? If it is like `module foo.main;` it will be listed under `foo` as a submodule rather than top-level since it is all organized by name. (if the

Re: Generating documentation help

2021-01-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 23:58:59 UTC, Tim wrote: The main issue is that those scripts aren't being added to index.html Do they have module definitions and doc comments in there somewhere? like here I have all kinds of things http://dpldocs.info/experimental-docs/index.html

Re: Generating documentation help

2021-01-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 23:51:00 UTC, Tim wrote: I'm creating a u-services based app so my apps need to be documented properly as well. I can get around this by defining them as modules but then adrdox doesn't add them to index.html Well, it does all .d files passed in directories

Re: What are the advantages of using betterC?

2021-01-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 17:44:03 UTC, Rempas wrote: Oh ok! So there is not advantage from using it like faster compile time, better performance etc. right? The default betterC build will compile about a quarter second faster than the default normal D build, but runtime performance is

Re: What are the advantages of using betterC?

2021-01-19 Thread Adam D. Ruppe via Digitalmars-d-learn
betterC is a niche restricted feature set. If you don't already have a use case in mind, I'd recommend avoiding it. It is for cases where you're stuck with certain limitations to integrate with the outside world. Like running on peculiar hardware or interoperating with certain outside

Re: Struggling with wchar[] to string conversion

2021-01-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 15:32:12 UTC, Stefan wrote: contains a szExePath member that is a wchar[260]. Converting this to a string succeeds (compiler does not complain) with me32.szExePath.text You need to slice it on length. That default conversion will include all 260 chars. So

Re: How do I make a template function that only accepts instances of a specific class?

2021-01-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 18 January 2021 at 19:34:52 UTC, Jack wrote: is that sytax derived from there? sort of. it is the type pattern matching "is expression" described here: https://dlang.org/spec/expression.html#IsExpression The is(A:B) thing technically means "if A is implicitly convertible to B"

Re: How do I enable visual styles?

2021-01-18 Thread Adam D. Ruppe via Digitalmars-d-learn
I haven't played with the pragma yet but I've done it before both with the file.exe.manifest XML file sitting alongside it and with the resource compiler before (you can use the same resource compilers for D as you use for C btw)

Re: How do I make a template function that only accepts instances of a specific class?

2021-01-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 18 January 2021 at 18:40:37 UTC, Jack wrote: isInstanceOf from std.traits seems to not work with class the way I need to. I'd like to make a template function accepts only class of a specified class type class A { } class B : A { } class C : A { } int f(T)(in A[int] arr) Use

Re: Generating documentation help

2021-01-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 17 January 2021 at 21:48:20 UTC, Paul Backus wrote: I recommend using adrdox instead: note you should be able to just dub run adrdox and it will spit out `generated_docs/files...` (assuming i haven't broken that recently)

Re: Beerconf January 2021

2021-01-16 Thread Adam D. Ruppe via Digitalmars-d-announce
On Saturday, 16 January 2021 at 16:28:34 UTC, Imperatorn wrote: Do you guys usually have some agenda or is it just drink n talk about D? The only agenda is MILKCONF or beerconf for people who aren't me People can gab about whatever comes to mind.

Re: Open question: what code pattern you use usually for null safety problem

2021-01-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 14 January 2021 at 18:24:44 UTC, ddcovery wrote: This is only an open question to know what code patterns you usually use to solve this situation in D: I'm almost never in this situation except for reading things like xml or json data that may be missing. So I just special

Re: Developing and running D GUI app on Android

2021-01-13 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 13 January 2021 at 20:23:22 UTC, H. S. Teoh wrote: Adam may be written a script for this, I'm not 100% sure. Yeah, my code does it all, though the auto-generation is more about accessing Java from D than vice versa, since implementing the D parts are simple. See the

Re: How to debug D on Linux

2021-01-13 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 13 January 2021 at 13:47:55 UTC, Roguish wrote: One specific question I have is: what's the difference between -g and -debug and -d-debug? -debug enables the `debug` keyword inside the D code itself. This lets you bypass other rules temporarily. For example void foo() pure {

Re: I'm creating a game purely written in D with the arsd library

2021-01-02 Thread Adam D. Ruppe via Digitalmars-d-announce
On Saturday, 2 January 2021 at 05:43:48 UTC, James Blachly wrote: Still, why not source code on Github? Is this really any different? Do you actually audit the source? simpledisplay is 17,000 lines. How much of that code is pure evil? Part of my twisted desire to burn the entire universe

Re: Field Initialiser Reused Across Object Instances

2021-01-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 1 January 2021 at 13:34:16 UTC, Adam wrote: A a = new A; // I would expect this to be called for each "new B". Your expectation is wrong for D. Since that's in a `static` context, it is run at compile time. Any variable marked `static`, `__gshared`, or is

Re: Associative Array Question

2020-12-31 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 1 January 2021 at 01:43:50 UTC, Chris Bare wrote: a1[10] = "testing a1"; this actually constructs a new thing since it is a straight x = y assignment. a2[10].name = "testing a2"; But this looks up something first. It doesn't construct a2[10],

Re: Missing D files

2020-12-31 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 31 December 2020 at 15:54:58 UTC, Paul Backus wrote: The D module corresponding to the C header `string.h` is `core.stdc.string`, but it's trying to import it as `std.c.string`. It used to be std.c.* many years ago, so it is probably just an old converter. Probably an easy

Re: 64-bit compilation in Wine

2020-12-29 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 29 December 2020 at 19:39:14 UTC, Raikia wrote: So interestingly, I actually got this to work by running "sudo wine" instead of just "wine". No idea why wine needs root access on the underlying system for wine to operate properly but ok... weird. i should try that too later.

Re: 64-bit compilation in Wine

2020-12-29 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 29 December 2020 at 17:49:19 UTC, Raikia wrote: "LLVM ERROR: Could not acquire a cryptographic context: Unknown error (0x80090017) I sometimes get this too, it seems to be a bug in wine. I actually kept an old version of wine around where it works, and a new version side by

Re: Our community seems to have grown, so many people are joining the Facebook group

2020-12-29 Thread Adam D. Ruppe via Digitalmars-d-announce
On Tuesday, 29 December 2020 at 15:06:07 UTC, Ola Fosheim Grøstad wrote: hostile ad hominem tone [...] deliberate attempt to fracture. tu quoque. Let's not assume any motives here. I wouldn't call it "official" either (and indeed, the title on facebook doesn't include that word) but no

Re: How to resize an image ? 樂

2020-12-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 27 December 2020 at 18:48:18 UTC, vnr wrote: The one given at the beginning by Adam D. Ruppe was fine with me, fyi i think I am going to move that resize code from image.d to a more independent imageresize.d or something. Same repo. Obviously won't affect you if you already using

Re: Exchange of data through socket connection.

2020-12-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 27 December 2020 at 17:49:10 UTC, BPS wrote: void[] buff; incommingConn.receive(buff); this has no actual space to receive anything void[] buff = ['a', 's', 'd', 'f']; sock.send(buff); sock.receive(buff); and the return value needs to be

Re: How to resize an image ? 樂

2020-12-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 25 December 2020 at 22:59:55 UTC, vnr wrote: tmp.data = cast(ubyte[]) myImageData; You set bytes here but an IndexedImage also needs a palette which you didn't set up. What format is your myImageData in? It might be more appropriate to set it to a TrueColorImage.

Re: typeid of variable of interface type holding reference to derived class

2020-12-24 Thread Adam D. Ruppe via Digitalmars-d-learn
Interfaces always give their own typeid, this is because they might point to an object that doesn't have RTTI (though the compiler SHOULD be able to figure that out statically, it doesn't try). To get the dynamic type, first cast it to Object, then type id. typeid(cast(Object) o) is

Re: Can I output strings using core.stdc.stdio?

2020-12-23 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 23 December 2020 at 13:06:37 UTC, drug wrote: static foreach (ulong i; 0..args.length) { static if (is(typeof(args[i]) == string)) printf("%s\n", args[i].toStringz); static if (is(typeof(args[i]) == int)) Putting some `else` in there would help too

Re: BetterC issues with ErupteD Vulkan binding typedef handles

2020-12-20 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 20 December 2020 at 15:45:59 UTC, ParticlePeter wrote: VkSemaphore[] wait_semaphores = [], // error: TypeInfo required does it still error if you just use = null? they work the same way but might avoid the annoying error.

Re: Floating point values in structs.

2020-12-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 18 December 2020 at 16:18:12 UTC, Dave P. wrote: Is the proper solution to change the struct definition to: yeah that's the best option right now I find the setting floats to nan pretty bizarre. yeah i wrote about it here not long ago

Re: Httparsed - fast native dlang HTTP 1.x message header parser

2020-12-15 Thread Adam D. Ruppe via Digitalmars-d-announce
On Tuesday, 15 December 2020 at 10:04:42 UTC, tchaloupka wrote: But if these benchmarks helps Adam to make some incremental improvements it's a plus and many of that can be pretty low hanging fruit. Yeah, I think the biggest benefit to changing this around is to just avoid creating

Re: Httparsed - fast native dlang HTTP 1.x message header parser

2020-12-14 Thread Adam D. Ruppe via Digitalmars-d-announce
On Tuesday, 15 December 2020 at 00:32:42 UTC, H. S. Teoh wrote: It may not be the fastest web module in the D world It actually does quite well, see: https://github.com/tchaloupka/httpbench (from the same OP here :) ) The header parser is nothing special, but since header parsing is a

Re: Httparsed - fast native dlang HTTP 1.x message header parser

2020-12-14 Thread Adam D. Ruppe via Digitalmars-d-announce
On Monday, 14 December 2020 at 21:59:02 UTC, tchaloupka wrote: * arsd's cgi.d - I haven't expected it to be so much slower than vibe-d parser, it's almost 3 times slower, but on the other hand it's super simple idiomatic D (again doesn't check or allow what RFC says it should and many tests

Re: Hex constant method starts from ".a": 0xCCCCCC.argb

2020-12-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 14 December 2020 at 16:11:16 UTC, Jacob Carlborg wrote: Or you can call it `rgba`. It seems to be what Wikipedia prefers [1]. The ordering here tends to reflect the bytes. So argb puts the alpha byte first in the array whereas rgba puts red first. But there's other ways here

Re: Using multiple mixin templates to implement operator overloading

2020-12-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 12 December 2020 at 20:26:00 UTC, Dennis wrote: If issue 19365 got fixed eeek I thought that was fixed but apparently not :( so yeah alias won't work for operator overloads. Does work for other functions so good technique to know but not here. So for op prolly go with the

Re: Using multiple mixin templates to implement operator overloading

2020-12-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 12 December 2020 at 18:14:31 UTC, Paul Backus wrote: IMO this is one of the stupider design decisions in D, but it's unlikely it will ever be fixed. It is useful in several other contexts though, including user overriding and private data stores for the mixin. The easiest

Re: SIGUSR1, SIGUSR2

2020-12-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 11 December 2020 at 17:29:12 UTC, Panke wrote: But somehow my process gets signalled with USR1 and USR2 all the time. If I do The garbage collector uses sig usr1/2 to pause threads so it can do its collection work. When debugging just ignore them. My .gdbinit has these lines:

Re: read till EOF from stdin

2020-12-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 11 December 2020 at 16:37:42 UTC, kdevel wrote: expected: program ends found: program still reading works for me looks like i have libc-2.30.so so i guess i have the fixed libc. Can you confirm what version you have? I did `ls /lib/libc*` to pick that out but it might be

Re: How to make Create Window Work?

2020-12-09 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 9 December 2020 at 17:45:18 UTC, Ruby The Roobster wrote: 0, // window menu here, that's the only int you do and I'm pretty sure that's supposed a be a HMENU which is a HANDLE, which is a void* rather than an int. C will cast 0 to null

Re: How to make Create Window Work?

2020-12-09 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 9 December 2020 at 17:37:16 UTC, Ruby The Roobster wrote: It's not the 'NULL' that's the error. I know. It doesn't compile because of the '0' . That is what I need to fix, since I want to make a WM_COMMAND for that button. Use lowercase `null` instead.

Re: How to make Create Window Work?

2020-12-09 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 9 December 2020 at 17:25:10 UTC, Ruby The Roobster wrote: CreateWindow("BUTTON".toUTF16z, // window class name fyi for a string literal like this you can just do "BUTTON"w.ptr // note the w This gives an error saying: Cannot pas argument of type 'int' to

Re: type suffix for character literal

2020-12-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 7 December 2020 at 22:26:52 UTC, Ben Jones wrote: Are there suffices (suffixes?) for character literals? nope. Is there a more succinct of writing "the literal 'x' as a dchar" than dchar('x')? You should rarely need to since there's implicit casting. but I think that is the

Re: Static on free functions

2020-12-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 7 December 2020 at 17:01:45 UTC, Dave P. wrote: Does `static` on a free function definition do anything? Nope, D allows a lot of useless attributes so it doesn't complain if you do certain things out of habit (or it is just a lazy implementation, I'm not sure which explanation

Re: Request assistance initializing struct instance at global scope

2020-12-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 7 December 2020 at 04:13:16 UTC, Andrew Edwards wrote: Given: === extern(C): char*[] hldr; Why is this extern(C)? A D array ere is probably wrong. In C, a `char*[] hldr = {...}` is actually represented in D as a static length array, like `char*[1] = [null];` It

Re: Is core.thread.osthread.Thread thread-safe?

2020-12-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 5 December 2020 at 18:48:19 UTC, tsbockman wrote: (The documentation for core.thread is broken right now, with dead links and at least one reference to an example that doesn't actually appear anywhere on the page.) im not sure about your other question but use my docs they

Re: ParameterIdentifierTuple returns empty strings

2020-12-02 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 2 December 2020 at 11:46:26 UTC, Andre Pany wrote: alias fpt = extern(C) nothrow void function(int a, int b); Function pointers don't really have parameter names. They are allowed for user habit and documentation purposes, but the compiler mostly* ignores them; they aren't

Four new entries in my D blog including cross-package doc search release

2020-11-30 Thread Adam D. Ruppe via Digitalmars-d-announce
I aim to write a weekly blog about D, often just summarizing some recent changes to my libraries or sometimes a random rant (at times very loosely related), but I don't always keep up. Usually when I miss a couple weeks, I just post the auto-generated forum index and move on. But in November,

Re: Why are default template parameters not permitted on class templates?

2020-11-29 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 29 November 2020 at 21:52:10 UTC, JN wrote: ValueHolder v2; // error Make it `ValueHolder!()` and it works. Default template params are only considered *after* it is clear a template needs to be instantiated. `ValueHolder` by itself is just the name of the template which is

Re: rgba.ptr[0] vs rgba[0]

2020-11-23 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 23 November 2020 at 17:34:27 UTC, visitor wrote: Hi all, I would like to know why in the code below, rgba.ptr[0] is used instead of rgba[0] and allowing the method to be @safe The .ptr[0] skips bounds checking. Since this example is static length with a constant index it

Re: lambdas with types

2020-11-20 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 20 November 2020 at 15:07:09 UTC, H. S. Teoh wrote: Wouldn't it be just syntactic sugar for a manually-declared helper template? Yeah, there's just both alias and enum helper templates that can both be useful at times so you might have to use those keywords in there somewhere too.

Re: lambdas with types

2020-11-20 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 20 November 2020 at 14:47:52 UTC, Paul Backus wrote: There is no way to create an anonymous template in D. I wish there was, maybe some day we can think of a way to add it to the language.

Re: DMD -i option, simple question...

2020-11-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 20 November 2020 at 03:06:37 UTC, WhatMeWorry wrote: The "..when this option is enabled..." is exactly the behavior I want, but how is it enabled? Is there an "all inclusive pattern" that I'm missing. dmd -i yourfile.d that's the default it is describing when you don't specify

Re: betterC question

2020-11-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 19 November 2020 at 00:20:50 UTC, Dibyendu Majumdar wrote: Okay thanks. Bad idea IMO. That's kinda how I see C taking the address of various things implicitly.

Re: betterC question

2020-11-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 19 November 2020 at 00:07:12 UTC, Dibyendu Majumdar wrote: int function() fp = test; This tries to *call* the function test and assign its return value to fp. You want to get the address.

Re: magically a static member on init?

2020-11-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 14 November 2020 at 23:20:55 UTC, Martin wrote: Is this intentional? In the current language design, yes. For the many users who ask this, no. All static initializers are run at compile time and refer to the static data segment - this is consistent across the language.

Re: question as to when a new command gets executed

2020-11-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 11 November 2020 at 22:10:38 UTC, WhatMeWorry wrote: Also, where is the memory, that new allocates? It is in the executable's static data block, just like if you declared a static array in the global space. I think this is D specific but I'm not sure about that.

Re: Value based overload resolution?

2020-11-09 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 9 November 2020 at 22:04:55 UTC, kdevel wrote: It appears to me that the overload resolution may depend on the /value/ of the function argument. According to [1] the type of 1 is int and that of 1L is long. That's not exactly true because of value range propagation. It is weird in

Re: How exactly does Tuple work?

2020-11-08 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 8 November 2020 at 13:57:08 UTC, Jan Hönig wrote: So it's like inheritance resolved at compile time. It's inheritance with virtual member functions without overhead. I am guessing only one alias works. And we use this, because struct can't do inheritance and interface is abstract.

Re: How exactly does Tuple work?

2020-11-08 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 8 November 2020 at 10:03:46 UTC, Jan Hönig wrote: Is there some recourse, which explains the `alias this`? If your object is used in a way that doesn't compile, the compiler will change `obj` to `obj.whatever_alias_this_is` and try again. So say you have struct S { int a;

Re: Why is vibe.d json serializer/deserializer so complex?

2020-10-31 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 31 October 2020 at 22:42:20 UTC, James Blachly wrote: be the nearest analog facility in D -- supposing we could agree on a standard API -- to facilitate pluggable serializers? interfaces? could even be informal interfaces where you just use the same function names so something

Re: rt/object.d

2020-10-29 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 29 October 2020 at 16:02:34 UTC, Ola Fosheim Grøstad: That is the same as the class decl, I meant the internals like vtable/typeinfo. I don't know what you mean. typeinfo isn't a part of Object and the vtable is built from those virtual methods. If you mean the *module* object

Re: rt/object.d

2020-10-29 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 29 October 2020 at 14:03:46 UTC, Ola Fosheim Grøstad wrote: The class definition for Object in the runtime object.d is "empty". Where can I find a description of the structure and fields of "class Object"? http://dpldocs.info/experimental-docs/object.Object.html

Re: nested module problem

2020-10-28 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 28 October 2020 at 22:43:12 UTC, mw wrote: I wonder what's the best way to resolve this conflict, i.e my local file name with 3rd party library dir name. Don't write any module with a single name unless you are guaranteed to never import it. pyd should have called it like

<    1   2   3   4   5   6   7   8   9   10   >