Re: synthesising instantiated template parameters and arguments

2020-10-28 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 28 October 2020 at 05:51:14 UTC, Nicholas Wilson wrote: class A(T,int,args...) {} alias C = A!(int, 0, float); I need `ScopeClass!C` to be template ScopeClass(C) { class Anon(T,int,args...) // name doesn't matter { // implement members with compile time

Re: How can I use class and wasm?

2020-10-28 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 26 October 2020 at 21:38:39 UTC, Jack wrote: I did consider do something like this but the class would only live in the function's lifetime, right? that wouldn't work if I need to pass the class around Right, you'd have to manage the memory somehow. One possibility is to malloc it

Re: Given a TypeInfo_Class, instance a new object of its type

2020-10-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 26 October 2020 at 21:57:18 UTC, Not A Rectangle wrote: Is this possible to do? Only if you know the type ahead of time, then you can cast it. Normally you'd probably just know an interface or base class it implements then you can cast to that, with the exact derived type being

Re: More elaborate asserts in unittests?

2020-10-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 21 October 2020 at 22:30:11 UTC, IGotD- wrote: When an assert fails in a unittest, I only get which line that failed. However, it would be very useful to see what the values are on either side of the unary boolean expression. Is this possible? try compiling with dmd

Re: LDC 1.24.0-beta1

2020-10-19 Thread Adam D. Ruppe via Digitalmars-d-announce
On Monday, 19 October 2020 at 14:20:02 UTC, Paul Backus wrote: Are we looking at the same instructions? ah i mixed it up with https://dlang.org/dmd-linux.html#installation in my brain without clicking the link :( sorry my bad those are ok.

Re: LDC 1.24.0-beta1

2020-10-19 Thread Adam D. Ruppe via Digitalmars-d-announce
On Monday, 19 October 2020 at 13:43:14 UTC, Bastiaan Veelo wrote: I'm not suggesting that this fills the need of newbies, but there is this: https://dlang.org/install.html. Nobody should ever follow those terrible instructions, they leave you so fragile in the event of future updates, takes

Re: LDC 1.24.0-beta1

2020-10-18 Thread Adam D. Ruppe via Digitalmars-d-announce
On Sunday, 18 October 2020 at 22:40:53 UTC, aberba wrote: Not sure what to do with the .7z file without manual tinkering. You can simply unzip it and use it directly. That's the best way to use most D compilers actually, then any versions can live side by side without affecting each other.

Re: Best way to confine project to 64 bit builds only?

2020-10-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 17 October 2020 at 14:50:47 UTC, NonNull wrote: I have inherited an open source C project that assumes that the size of a long and the size of a pointer are the same static assert(long.sizeof == void*.sizeof);

Re: Packing of Struct Fields

2020-10-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 17 October 2020 at 13:00:59 UTC, Per Nordlöw wrote: I understand that. I don't want the alignment of `S` to change. I want the padding after `s` That padding is part of S. It is at the end, after its fields, but still part of it. S's layout doesn't depend on what else is around

Re: Packing of Struct Fields

2020-10-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 17 October 2020 at 12:44:44 UTC, Per Nordlöw wrote: Can `align`s be inserted in S or/and T so that T is packed to 8 bytes but still aligned to 8 bytes? Yes. Put an align on the OUTSIDE of the struct you are nesting, then put one INSIDE the struct you want the contents packed.

Re: Forward referencing functions in D

2020-10-16 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 16 October 2020 at 19:55:53 UTC, wilcro wrote: Evidently, I am misunderstanding something very elemental here; thanks for any enlightenment regarding this. Inside a function things happen in order, top to bottom, including declarations (you can only access local variables after

Re: How can I use class and wasm?

2020-10-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 16 October 2020 at 03:04:25 UTC, Jack wrote: How can I allocate memory for this class? It is possible but not easy without druntime. If you are using -betterC, you can use extern(C++) classes with extern(D) members. The compiler will let you declare that. But then you need to

Re: How do I make this function from module public?

2020-10-13 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 14 October 2020 at 01:46:11 UTC, Jack wrote: extern(C): int mul(int a, int b) { return a * b;} mark it `export` as well and then be sure you are compiling in this module as well, it must be included on the ldc command line along with wasm.d

Re: Range format specifiers in other languages?

2020-10-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 12 October 2020 at 00:46:37 UTC, Imperatorn wrote: To people trying to learn, why is that % before ( needed in the format string? The %( ... %) stuff is expanded and repeated for each element inside the given array.

Re: Win32Api GetDlgItemText How make buffer with no fixed size?

2020-10-10 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 10 October 2020 at 10:15:03 UTC, Marcone wrote: wchar[100] buffer; // I don't want fixed size :( wchar[] buffer; // no fixed size buffer.length = GetWindowTextLength(hwn); // set it to the text length of the window // now get the text GetDlgItemText(hwn, widget, buffer.ptr,

Re: Taking arguments by value or by reference

2020-10-04 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 4 October 2020 at 15:30:48 UTC, IGotD- wrote: I don't agree with this, especially if the struct is 432 bytes. It takes time and memory to copy such structure. If the compiler chooses to inline the function (which happens quite frequently with optimizations turned on), no copy takes

Re: Getting Field Names of a specific UDA in compile time.

2020-10-03 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 3 October 2020 at 13:10:31 UTC, realhet wrote: I only managed to get the string[] by making a static foreach, but I don't know how to put that in an enum xxx = ...; statement. There's always other ways but general rule: if you can get it one way, just wrap that up in a function

Re: Whats going on with this?

2020-10-03 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 2 October 2020 at 23:28:04 UTC, claptrap wrote: I cant see anything in the struct docs explaining why that array on the right hand side is automatically converted to a constructor call. I'm not sure exactly where it is in the docs but that's perfectly normal. Any declaration

Re: vibe.de multiple ports.

2020-09-30 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 30 September 2020 at 11:23:59 UTC, seany wrote: auto router = new URLRouter; router.post("/archive", ); router.get("/archive", ); auto settings = new HTTPServerSettings; settings.port = port; settings.bindAddresses = ["::1",

Re: How to write a counterpart to C++ std::invoke that works with both free functions and methods?

2020-09-28 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 27 September 2020 at 05:22:36 UTC, 60rntogo wrote: How would I check if it is actually a free function? but this doesn't even compile since I defined add inside my main function ah that's not a free function!! That's a nested function and thus actually has a hidden argument.

Re: assert format of a string before a mixin

2020-09-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 27 September 2020 at 21:38:43 UTC, ddcovery wrote: i.e. checking this Regex expression `^[a-zA-Z_]*[a-zA-Z0-9_]*[a-zA-Z][a-zA-Z0-9_]*$` Is there any way to check a regular expression at compile time? Not really and I'd actually suggest not trying because even if it did work,

Re: HTTP frameworks benchmark focused on D libraries

2020-09-27 Thread Adam D. Ruppe via Digitalmars-d-announce
On Sunday, 27 September 2020 at 10:08:24 UTC, tchaloupka wrote: * new RAW tests in C to utilize epoll and io_uring (using liburing) event loops - so we have some ground base we can compare against I fixed some buffering issues in cgi.d and, if you have the right concurrency level that

Re: HTTP frameworks benchmark focused on D libraries

2020-09-27 Thread Adam D. Ruppe via Digitalmars-d-announce
I fixed my event loop last night so I'll prolly release that at some point after a lil more testing, it fixes my keep-alive numbers... but harms the others so I wanna see if I can maintain those too.

Re: How to write a counterpart to C++ std::invoke that works with both free functions and methods?

2020-09-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 26 September 2020 at 22:58:44 UTC, 60rntogo wrote: I get the error "undefined identifier isValid". How can I make this work? This part is easy, you need to give the name like assert(invoke!(Foo.isValid)(foo, 3)); Now, the other part is tricky, and a new feature just released

Re: beerconf September!

2020-09-26 Thread Adam D. Ruppe via Digitalmars-d-announce
On Saturday, 26 September 2020 at 18:44:06 UTC, Andrei Alexandrescu wrote: What time is it and what's the chat link? A bunch of us coming and going at all hours, decent group on now. https://meet.jit.si/Dlang2020SeptemberBeerConf password: -preview=in

Re: How create Win32api Thread in Dlang?

2020-09-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 26 September 2020 at 03:08:56 UTC, Marcone wrote: #include import core.sys.windows.windows WINAPI extern(Windows) int main(int argc, char *argv[]) { int main(string[] args) CreateThread(NULL, 0, threadFunc, NULL, 0, NULL); CreateThread(null, 0, , null, 0, null);

Re: uda pattern foo and foo(val)

2020-09-22 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 23 September 2020 at 02:07:04 UTC, Steven Schveighoffer wrote: I just said pragma(msg, __traits(getAttributes, z)) Ah, ok, this is weird, `pragma(msg, __traits(getAttributes, z)[0])` works just fine! But that might be adequate for you - just loop over the attributes and use

Re: uda pattern foo and foo(val)

2020-09-22 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 23 September 2020 at 01:45:46 UTC, Steven Schveighoffer wrote: @foo int z; // Error: cannot interpret foo(T)(T val) at compile time Where do you get that error? Is it from phobos' thing? cuz I copy/pasted your code and it compiled. You can also just use a struct as the uda if

Re: Why private methods cant be virtual?

2020-09-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 21 September 2020 at 23:30:30 UTC, H. S. Teoh wrote: It looks like a bug to me. No, it is by design: https://dlang.org/spec/function.html#virtual-functions see point 2.

Re: HTTP frameworks benchmark focused on D libraries

2020-09-20 Thread Adam D. Ruppe via Digitalmars-d-announce
With my lib, the -version=embedded_httpd_threads build should give more consistent results in tests like this. The process pool it uses by default in a dub build is more crash resilient, but does have a habit of dropping excessive concurrent connections. This forces them to retry which

Re: vibe.d: How to get the conent of a file upload ?

2020-09-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 20 September 2020 at 01:51:22 UTC, wjoe wrote: Would even be more awesome if it provided a function which could be called from a custom main on top of the FancyMain. I find e.g. custom parsing of command line arguments incredibly useful. Yea, the version 2.0 stuff inside cgi.d does

Re: vibe.d: How to get the conent of a file upload ?

2020-09-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 19 September 2020 at 20:17:06 UTC, aberba wrote: Arsd cgi.d might be what you want if you want to it your way as its more low-level interface-wise. Eh, it depends. My lib lets you do as much or as little as you want. About ten years ago, I wrote a framework on top that

Re: Cannot call @system funciton (stdout)

2020-09-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 19 September 2020 at 13:56:53 UTC, Anonymouse wrote: Is there a way to detect programmatically if I'm in an environment where I need to manually set line buffering? Part of the problem is the IDE console and cygwin too I believe both *look* like a pipe to the program instead of

Re: Building LDC runtime for a microcontroller

2020-09-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 17 September 2020 at 09:53:57 UTC, Remi wrote: My problem here is mostly understanding the __initZ symbol and where it comes from. The compiler generates that when it spits out something that uses TypeInfo, which is a lot of things: ~= and ~ operators on built in arrays, the new

Re: vibe.d: How to get the conent of a file upload ?

2020-09-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 18 September 2020 at 22:02:07 UTC, aberba wrote: In this case you want to get the file(s) in memory...in the form of bytes (or buffer) and probably set a file size limit. Its all doable through a library but such a library doesn't exist in D yet. At least not that I know of. I

Re: Building LDC runtime for a microcontroller

2020-09-17 Thread Adam D. Ruppe via Digitalmars-d-learn
fyi my baby was just born i'll come back to this but it might be a day or two

Re: What kind of mangling has the LDC2 -X JsonFile "deco" field?

2020-09-16 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 17 September 2020 at 03:06:45 UTC, realhet wrote: Anyone can help me telling how to decode these please? so here's a cool trick to get hte other demanglers to help. Just prepend _D4name to the string. so like: $ ./ddemangle _D4nameFAyaZE3het8keywords10KeywordCat

Re: What kind of mangling has the LDC2 -X JsonFile "deco" field?

2020-09-16 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 17 September 2020 at 03:06:45 UTC, realhet wrote: I'm trying to get information from the JsonFile produced by LDC2, but having no clue how to decode this: For example: header: KeywordCat kwCatOf(int k) "deco" : "FAyaZE3het8keywords10KeywordCat", That's a D mangle but just of

Re: Building LDC runtime for a microcontroller

2020-09-16 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 16 September 2020 at 17:59:41 UTC, Remi wrote: I tried to modify the hello.d example from your blog post. It works without changes but when I tried to do a string concatenation Yeah, concatenation is one of the features that uses druntime, and specifically, it is done through

Re: enum and const or immutable ‘variable’ whose value is known at compile time

2020-09-16 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 16 September 2020 at 17:12:47 UTC, Cecil Ward wrote: then is there any downside to just using enum all the time? For a non-string array, enum may give runtime allocations that static immutable won't. Generally think of enum as being replaced with the literal representation

Re: importing a symbol without specifying a subpackage name

2020-09-16 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 16 September 2020 at 13:36:22 UTC, 60rntogo wrote: except that I tried doing this in foo.d and then the compiler yelled at me. Yeah, this is the one case where the compiler is picky about the directory structure and filename. It *must* be package.d. (blargh.)

Re: importing a symbol without specifying a subpackage name

2020-09-16 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 16 September 2020 at 13:30:57 UTC, 60rntogo wrote: I'm curious, how is this behavior achieved in the standard library? They define an additional file std/package.d (and std/algorithm/package.d btw) that lists off module std; public import std.algorithm; public import

Re: Newbie question: Return a locally allocated variable

2020-09-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 14 September 2020 at 16:29:11 UTC, Fitz wrote: I expect the following code below to create 10 items with 10 different addresses, instead they all have the same address? You are taking the address of the local variable holding reference, not the reference itself. class Bob { }

Re: Why does a directly defined constructor hide a mixed-in constructor?

2020-09-13 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 13 September 2020 at 12:34:06 UTC, 60rntogo wrote: However, if I directly insert the contents of X into Bar instead of mixing it in, it compiles just fine. What's going on here? You can override members from mixin templates by giving a member with the same *name* (not the same

Re: Passing string array to C

2020-09-10 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 10 September 2020 at 14:31:41 UTC, Andre Pany wrote: Why does it crash? You messed up the pointers. A string is one star. An array of strings is two stars. A pointer to an array of strings is /three/ stars. --- import std; void main() { size_t* i; // this need not be

Re: UDA inheritance

2020-09-10 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 10 September 2020 at 13:06:41 UTC, Joseph Rushton Wakeling wrote: `hasUDA!(T, AnotherUDA)` ...do you have to use hasUDA? The language works with class UDAs, but hasUDA doesn't support it. If you write your own test function though you can: ``import std.traits; class BaseUDA {

Re: D mentionned in the ARTIBA webzine for an article on Silq

2020-09-08 Thread Adam D. Ruppe via Digitalmars-d-announce
On Tuesday, 8 September 2020 at 08:33:35 UTC, aberba wrote: Now I really want to sew your D web workflow and stack in use at DConf Online. Don't say no!! Yeah, I did tell the dconf people I'd do a livestream thing if they need me, but I was thinking about making an Asteroids clone or

Re: GC.LDC2 on Android

2020-09-08 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 8 September 2020 at 12:47:11 UTC, Danny Arends wrote: How can I figure out which linker is used ? When performing a dub build, it just mentions that ldc2 is used for linking If you are using the d_android setup thing, it actually edits ldc2.conf so it uses the linker from the NDK.

Re: Are @safe unittests actually checked for safety?

2020-09-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 7 September 2020 at 20:33:26 UTC, 0xEAB wrote: Are unittests that are marked @safe actually checked for safety? https://github.com/dlang/phobos/blob/v2.093.1/std/file.d#L4937 How comes this unittest is @safe when `dirEntries` appears to be @system? I see what happened now: those

Re: Building LDC runtime for a microcontroller

2020-09-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 7 September 2020 at 20:55:54 UTC, IGotD- wrote: I guess this was written before betterC existed. Well, -betterC existed even then, but it was *completely* useless. It didn't become useful until 2016 or 2017. But around that same time, going minimal runtime got even easier, so I

Re: D mentionned in the ARTIBA webzine for an article on Silq

2020-09-07 Thread Adam D. Ruppe via Digitalmars-d-announce
On Wednesday, 2 September 2020 at 13:31:25 UTC, Adam D. Ruppe wrote: I could write that in a few hours. I went ahead and did it: https://dwidder.arsdnet.net/ might move later but eh the basics work i think.

Re: DConf Online 2020 Submission Deadline Extended

2020-09-05 Thread Adam D. Ruppe via Digitalmars-d-announce
On Monday, 31 August 2020 at 08:36:09 UTC, Mike Parker wrote: So send me your <= 5-minute videos describing your talks, folks! There's basically zero chance of me doing this part specifically. But on the other hand, between my self-loathing and procrastination, I probably won't record a talk

Re: D mentionned in the ARTIBA webzine for an article on Silq

2020-09-04 Thread Adam D. Ruppe via Digitalmars-d-announce
On Wednesday, 2 September 2020 at 18:42:25 UTC, starcanopy wrote: But if you do create an ad-hoc service, I'd very much use it if you didn't necessitate registration with an email. So I think some kind of user account is useful and I figure I'll require them... but it will be just a random

Re: D mentionned in the ARTIBA webzine for an article on Silq

2020-09-04 Thread Adam D. Ruppe via Digitalmars-d-announce
On Friday, 4 September 2020 at 17:47:39 UTC, James Lu wrote: And there's a Facebook? Seriously? A random user set it up and tries to push it but there's not much activity. And Slack? That's more used by like dconf coordinators. The places new people come on for chat is just the irc and

Re: Bug in import(...) on Windows?

2020-09-02 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 2 September 2020 at 18:40:55 UTC, Andrey Zherikov wrote: If I provide -Jfoo to dmd, doesn't it mean my consent to use the contents of directory foo? Yeah, but dmd has been inconsistent on platforms about if it allows subdirectories. Right now I think it just strips all slashes

Re: Bug in import(...) on Windows?

2020-09-02 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 2 September 2020 at 17:39:04 UTC, Andrey Zherikov wrote: Is this a bug in dmd? I think it is an old bug filed (I can't find it though) about inconsistent platform behavior but it is allowed by spec for the compiler to reject any path components. import("") is supposed to just

Re: D mentionned in the ARTIBA webzine for an article on Silq

2020-09-02 Thread Adam D. Ruppe via Digitalmars-d-announce
On Wednesday, 2 September 2020 at 07:38:01 UTC, JN wrote: One thing I always feel this forum is missing is a section for work in progress projects, even if they never end up anywhere. Yeah, I often want a place to just gab. I kinda do in my blog, but that's more often something that is more

Re: I think Associative Array should throw Exception

2020-09-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 1 September 2020 at 18:55:20 UTC, Steven Schveighoffer wrote: This is the big sticking point -- code that is nothrow would no longer be able to use AAs. It makes the idea, unfortunately, a non-starter. You could always catch it though. But I kinda like things the way they are

Re: How to create compile-time container?

2020-08-31 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 31 August 2020 at 20:39:10 UTC, Andrey Zherikov wrote: How can I do that? You can use a normal string[] BUT it is only allowed to be modified inside its own function. Then you assign that function to an enum or whatever. string[] ctGenerate() { string[] list; list ~=

Re: what's this Error: corrupt MS Coff object module

2020-08-24 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 25 August 2020 at 01:08:49 UTC, mw wrote: Is it safe to just delete all the: yup. I have to do this every other week on my work box to keep its hard drive from filling up lol

Re: what's this Error: corrupt MS Coff object module

2020-08-24 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 25 August 2020 at 00:41:27 UTC, mw wrote: How to fix this Coff object issues? there's two library formats: coff and omf. omf is the old one that dmd assumes without arguments. coff is the new one with `dmd -m32mscoff` or `dmd -m64`. I would guess one of those libs was built

Re: Introspecting a package for submodules

2020-08-24 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 24 August 2020 at 22:32:52 UTC, Anonymouse wrote: How do I do this? (Is there some other way?) Not really a way. A package doesn't quite exist in D; there is no formal construct that is a package and has a defined list if stuff. It is just whatever modules are compiled in that

Re: opIndex for type list

2020-08-24 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 24 August 2020 at 14:19:14 UTC, data pulverizer wrote: I am trying to implement `opIndex` (e.g. T[i]) for types in a struct. So for I have `length`: Can't really do that, the operator overloads work on instances instead of static types. AliasSeq is magical because it just gives a

Re: __FILE__ and __LINE__ in case of import expression

2020-08-23 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 23 August 2020 at 12:50:36 UTC, Andrey Zherikov wrote: Even this approach can lead to unclear result if you move 'q{...}' outside of mixin: Yes, that's why I write it very specifically the way I do, with q{ and mixin on the same line.

Re: __FILE__ and __LINE__ in case of import expression

2020-08-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 21 August 2020 at 22:12:48 UTC, Steven Schveighoffer wrote: Who does that though? An incompetent coder: http://dpldocs.info/experimental-docs/source/arsd.cgi.d.html#L5713 http://dpldocs.info/experimental-docs/source/arsd.cgi.d.html#L5943

Re: __FILE__ and __LINE__ in case of import expression

2020-08-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 21 August 2020 at 21:42:21 UTC, Steven Schveighoffer wrote: While not necessarily a "bug", it's not very useful. Maybe not in this case, but it is perfectly accurate for cases like: mixin(q{ some code here }); Where it will actually line back up to the original file's line

Re: __FILE__ and __LINE__ in case of import expression

2020-08-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 21 August 2020 at 21:06:11 UTC, Steven Schveighoffer wrote: The hybrid line number (original source line number + mixin line number) seems like a bug to me. I'm not so sure without seeing all the code. Remember to the compiler, the mixin thing is just a big string literal at the

Re: __FILE__ and __LINE__ in case of import expression

2020-08-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 21 August 2020 at 14:01:24 UTC, Andrey Zherikov wrote: mixin(import("foo.d")); // line #17(2) Why are you doing this? This kind of thing is almost never an ideal solution in D. See, the compiler just sees a big string literal there. It isn't a separate file at that

Re: BetterC + WASM Update

2020-08-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 19 August 2020 at 21:24:23 UTC, Mike Brown wrote: I can see that LDC supports WASM output, and I believe this requires BetterC to be enabled? Not really but anything beyond -betterC is still kinda diy right now. So I happened to do port my little tetris game in D to wasm just

Re: Creating a pointer array

2020-08-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 19 August 2020 at 13:03:54 UTC, data pulverizer wrote: How do you create an array of pointers in D? I tried something like ``` double* []y; ``` I'd write it double*[] y; but yeah that's it. Error: only one index allowed to index double[] That must be at the usage point

Re: Types of lambda args

2020-08-16 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 17 August 2020 at 00:20:24 UTC, Cecil Ward wrote: In a lambda, how do we know what types the arguments are? In something like (x) => x * x In that the compiler figures it out from usage context. So if you pass it to a int delegate(int), it will figure x must be int. - there

Re: Leaving a pointer to it on the stack

2020-08-13 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 13 August 2020 at 20:04:59 UTC, Andre Pany wrote: Hi, in the specification https://dlang.org/spec/interfaceToC.html#storage_allocation there is this paragraph: "Leaving a pointer to it on the stack (as a parameter or automatic variable), as the garbage collector will scan the

Re: tetris in D in webassembly

2020-08-11 Thread Adam D. Ruppe via Digitalmars-d-announce
On Tuesday, 11 August 2020 at 04:10:10 UTC, starcanopy wrote: This is really cool. This idea, especially, titillates me: That's actually easy enough to do I just went ahead and made it. so behold: http://webassembly.arsdnet.net/ and the source is pushed up to github, with just a little bit

Re: tetris in D in webassembly

2020-08-11 Thread Adam D. Ruppe via Digitalmars-d-announce
On Tuesday, 11 August 2020 at 13:22:02 UTC, jmh530 wrote: The blog post says it is space bar. Tripped me up too. Yeah, I learned yesterday that there's a whole other PC tetris world I had no clue about. I only ever played the Nintendo/ELORG version on the NES. On that, dpad is left, down,

Re: tetris in D in webassembly

2020-08-10 Thread Adam D. Ruppe via Digitalmars-d-announce
On Monday, 10 August 2020 at 21:30:53 UTC, matheus wrote: By the way you should post on reddit (/r/programming) if you haven't already. I don't really do reddit. I sometimes troll in the comments but it isn't a site I care for. That said if you or someone else wanted to and post the link,

Re: tetris in D in webassembly

2020-08-10 Thread Adam D. Ruppe via Digitalmars-d-announce
On Monday, 10 August 2020 at 16:24:02 UTC, Steven Schveighoffer wrote: Bug report: the score doesn't increase for me when I complete a line ;) The reason for that is actually explained in the article; has to do with webassembly not blocking on eventLoop and the program was written with the

tetris in D in webassembly

2020-08-10 Thread Adam D. Ruppe via Digitalmars-d-announce
http://webassembly.arsdnet.net/ tetris.d source here: http://dpldocs.info/this-week-in-d/Blog.Posted_2020_08_03.html#tetris-in-d web assembly source and explanation here: http://dpldocs.info/this-week-in-d/Blog.Posted_2020_08_10.html Short version: BARE MINIMUM druntime port to webassembly

Re: dpldocs not update

2020-08-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 7 August 2020 at 21:58:10 UTC, Per Nordlöw wrote: https://phobos-next.dpldocs.info/index.html aren't updated. For instance the file dpldocs never auto-updates. You must either link to a specific tagged version like this: https://phobos-next.dpldocs.info/v0.3.9/index.html Or go

Re: How does D's templated functions implementation differ from generics in C#/Java?

2020-08-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 7 August 2020 at 21:03:47 UTC, aberba wrote: Syntactically they look the same (although D's can do more things) so I'm trying to understand how why in D it's called template but in languages like C#/Java they're generics. In D, a copy of the function is created for each new

Re: Non-recursive maxSizeOf

2020-08-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 6 August 2020 at 13:18:40 UTC, Per Nordlöw wrote: mixin(T.stringof ~ " _store" ~ T.mangleof ~ Never ever use mixin(T.stringof). Always just use mixin("T") instead. mixin("T _store", T.mangleof /* or just idx is gonna be better */,";"); Though I doubt this is

Re: Non-recursive maxSizeOf

2020-08-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 6 August 2020 at 01:23:33 UTC, Per Nordlöw wrote: How does the memory usage and speed of this code compare to the variant that uses template instantiations? I haven't tested this specifically, but similar tests have come in at like 1/10th the memory and compile time cost. There

Re: Non-recursive maxSizeOf

2020-08-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 6 August 2020 at 01:17:51 UTC, lithium iodate wrote: more love for phobos pls That would add a lot to the cost and bring no real benefit

Re: Non-recursive maxSizeOf

2020-08-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 6 August 2020 at 00:58:39 UTC, Per Nordlöw wrote: Is it possible to implement in a non-recursive way? It is very easy too... just write an ordinary function: size_t maxSizeOf(T...)() { size_t max = 0; foreach(t; T) if(t.sizeof > max)

Re: Template functions inside interface

2020-08-04 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 4 August 2020 at 13:36:15 UTC, Zans wrote: Is there any way to declare template functions inside interface and then override them in a class? No, the templates in the interface are automatically considered `final`. So the body must be in the interface too to avoid that undefined

Re: Are function literals deprecated?

2020-08-03 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 3 August 2020 at 14:23:56 UTC, Victor L Porton wrote: Are function literals considered deprecated in regard of using delegates instead? No, they both work well for different purposes.

Re: Question about UDAs

2020-08-02 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 3 August 2020 at 03:00:08 UTC, Cecil Ward wrote: When practically speaking would you use UDAs? A real-world use-case? They are useful when you want to attach some kind of metadata to the declarations for a library to read. For example, my script.d looks for `@scriptable` for

Re: Equivalent of C++ #__VA_ARGS__

2020-08-02 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 2 August 2020 at 16:05:07 UTC, Ronoroa wrote: That doesn't seem to stringize the args part like in #__VA_ARGS__ oh yeah i missed that part. D basically can't do that exactly, but if you pass the args as template things directly you can do this: --- void main(string[] args) {

Re: Equivalent of C++ #__VA_ARGS__

2020-08-02 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 2 August 2020 at 15:30:27 UTC, Ronoroa wrote: How do I achieve equivalent semantics of following C++ code? ``` #define dbg(...) std::cout << __LINE__ << #__VA_ARGS__ << " = " << print_func(__VA_ARGS__) << std::endl; ``` You probably just want void dbg(Args...)(Args args, size_t

Re: How do I convert a Base64 image url string to a png/jpg image file?

2020-07-30 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 30 July 2020 at 12:22:46 UTC, aberba wrote: I'm able to decode it to a buffer but the trouble is getting it from buffer to an actual image file. Any library function combination I can use? I don't think I wrote it as a library yet, but the idea is pretty simple: they all start

Re: Article: the feature that makes D my favorite programming language

2020-07-25 Thread Adam D. Ruppe via Digitalmars-d-announce
On Saturday, 25 July 2020 at 11:12:16 UTC, aberba wrote: Oop! Chaining the writeln too could have increased the wow factor. I didn't see that. oh I hate it when people do that though, it just looks off to me at that point.

Re: miscellaneous array questions...

2020-07-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 21 July 2020 at 19:20:28 UTC, Simen Kjærås wrote: Walter gives some justification in the post immediately following: whelp proves my memory wrong!

Re: miscellaneous array questions...

2020-07-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 21 July 2020 at 13:16:44 UTC, IGotD- wrote: Either the array will hit that page during initialization or something else during the execution. But the array isn't initialized in the justification scenario. It is accessed through a null pointer and the type system thinks it is fine

Re: std/process.d: nothrow functions which throw (in struct ProcessPipes)

2020-07-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 21 July 2020 at 12:44:23 UTC, Drone1h wrote: Would it be possible to explain this, please ? nothrow only applies to Exception and its children. Error is a different branch. Error means you have a programming error and cannot be caught and recovered (though the compiler allows

Re: miscellaneous array questions...

2020-07-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 20 July 2020 at 22:05:35 UTC, WhatMeWorry wrote: How does that pertain to an array? C arrays work as pointers to the first element and D can use that style too. 2) "The total size of a static array cannot exceed 16Mb" What limits this? The others aren't wrong about stack size

Re: Is there a compiler option to list all functions executed at compile time when compiling a file?

2020-07-20 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 20 July 2020 at 16:01:53 UTC, blizzard wrote: I am trying to learn D and knowing when code is run at compile time would be good for learning what functions can be used without thinking much about performance. No function is ever run at compile time unless you specifically request

Re: Good way to send/receive UDP packets?

2020-07-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 18 July 2020 at 16:00:09 UTC, Dukc wrote: I have a project where I need to take and send UDP packets over the Internet. Only raw UDP I wrote an example using phobos on my blog a while ago that might help you get started:

Re: Bind C++ class to DLang : undefined reference to `Canvas::Foo()'

2020-07-13 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 13 July 2020 at 09:34:35 UTC, zoujiaqing wrote: # dmd source/main.d Canvas.o -L-lstdc++ && ./main [1]49078 segmentation fault ./main On my computer I got this warning out of the compiler: libstdc++ std::__cxx11::basic_string is not yet supported; the struct contains an

Re: GDC and DMD incompatability, can both be used?

2020-07-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 11 July 2020 at 04:28:32 UTC, cy wrote: 125 | static foreach (string member; FieldNameTuple!T) { The word "static" there can probably be removed and have it work exactly the same way. Worth a try. Does gdc not support static foreach at all? only the newest gdc

Re: Decimal string to floating point conversion with correct half-to-even rounding

2020-07-07 Thread Adam D. Ruppe via Digitalmars-d-announce
On Tuesday, 7 July 2020 at 13:00:04 UTC, Steven Schveighoffer wrote: Doing that these days would be silly. You can depend on a specific version of a repository without problems. I always have problems when trying to do that. git submodules bring pretty consistent pain in my experience. But

Re: Decimal string to floating point conversion with correct half-to-even rounding

2020-07-07 Thread Adam D. Ruppe via Digitalmars-d-announce
On Tuesday, 7 July 2020 at 13:01:10 UTC, 9il wrote: This would be good advertising for DFL, haha. I don't know what you mean...

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