Re: is there a way to get the identifier (call it name) of what is being passed to a function ?

2021-07-18 Thread someone via Digitalmars-d-learn
On Monday, 19 July 2021 at 03:05:24 UTC, Paul Backus wrote: On Monday, 19 July 2021 at 01:45:27 UTC, SealabJaster wrote: On Monday, 19 July 2021 at 01:26:25 UTC, someone wrote: ... Not 100% sure this works in all cases, but this version doesn't need the caller to make use of a mixin:

Re: is there a way to get the identifier (call it name) of what is being passed to a function ?

2021-07-18 Thread SealabJaster via Digitalmars-d-learn
On Monday, 19 July 2021 at 03:51:02 UTC, SealabJaster wrote: ... There's also Ali Cehreli's book, which is excellent. e.g. here's the section on UDAs: http://ddili.org/ders/d.en/uda.html

Re: is there a way to get the identifier (call it name) of what is being passed to a function ?

2021-07-18 Thread SealabJaster via Digitalmars-d-learn
On Monday, 19 July 2021 at 01:56:21 UTC, someone wrote: ... Prepare yourself, as you may become a metaprogramming junkie in the near future. Throw in `static if`[0] `static foreach`[1] `string mixin()`[2] `CTFE`[3] and make some crazy, random, arcane mess of fun spaghetti. I've wrote

Re: is there a way to get the identifier (call it name) of what is being passed to a function ?

2021-07-18 Thread SealabJaster via Digitalmars-d-learn
On Monday, 19 July 2021 at 03:05:24 UTC, Paul Backus wrote: ... Yea, that's true.

Re: is there a way to get the identifier (call it name) of what is being passed to a function ?

2021-07-18 Thread Paul Backus via Digitalmars-d-learn
On Monday, 19 July 2021 at 01:45:27 UTC, SealabJaster wrote: On Monday, 19 July 2021 at 01:26:25 UTC, someone wrote: ... Not 100% sure this works in all cases, but this version doesn't need the caller to make use of a mixin: https://run.dlang.io/is/3jLxLz If you only need to print

Re: is there a way to get the identifier (call it name) of what is being passed to a function ?

2021-07-18 Thread someone via Digitalmars-d-learn
On Monday, 19 July 2021 at 01:45:27 UTC, SealabJaster wrote: On Monday, 19 July 2021 at 01:26:25 UTC, someone wrote: ... Not 100% sure this works in all cases, but this version doesn't need the caller to make use of a mixin: https://run.dlang.io/is/3jLxLz http://dlang.org/traits.html ...

Re: is there a way to get the identifier (call it name) of what is being passed to a function ?

2021-07-18 Thread SealabJaster via Digitalmars-d-learn
On Monday, 19 July 2021 at 01:26:25 UTC, someone wrote: ... Not 100% sure this works in all cases, but this version doesn't need the caller to make use of a mixin: https://run.dlang.io/is/3jLxLz

Re: Including a file

2021-07-18 Thread Mathias LANG via Digitalmars-d-learn
On Sunday, 18 July 2021 at 17:48:53 UTC, Vindex wrote: On Sunday, 18 July 2021 at 17:31:24 UTC, Adam D Ruppe wrote: On Sunday, 18 July 2021 at 17:28:07 UTC, Vindex wrote: Error: file "thing.json" cannot be found or not in a path specified with -J You need to specify the path where it is

Re: is there a way to get the identifier (call it name) of what is being passed to a function ?

2021-07-18 Thread someone via Digitalmars-d-learn
On Monday, 19 July 2021 at 00:52:39 UTC, Paul Backus wrote: The closest you can get is to use a string mixin: ```d enum debugWriteln(string expression) = `writeln(q"(` ~ expression ~ `)", " = ", ` ~ expression ~ `);`; // Usage: mixin(debugWriteln!"lobjExchanges.count"); ``` clever :)

Re: is there a way to get the identifier (call it name) of what is being passed to a function ?

2021-07-18 Thread Paul Backus via Digitalmars-d-learn
On Monday, 19 July 2021 at 00:07:25 UTC, someone wrote: Every time I use it, of course, I have to double-type the tag and the value. I wonder if there's some mechanism to just type the following: ```d debugwriteln(lobjExchanges.count); ``` ... and some way to get the identifier of what's

is there a way to get the identifier (call it name) of what is being passed to a function ?

2021-07-18 Thread someone via Digitalmars-d-learn
I know the answer for this will be a resoundingly no, but, anyway ... I have, more-or-less, the following function: ```d public void debugwriteln(typeValue)( const dstring lstrTag, const typeValue lstrValue ) { writeln(console.colorizeYellow(r"debugging"d), r" → "d, lstrTag,

Re: LLVM asm with constraints, and 2 operands

2021-07-18 Thread Guillaume Piolat via Digitalmars-d-learn
On Sunday, 18 July 2021 at 18:48:47 UTC, Basile B. wrote: On Sunday, 18 July 2021 at 18:47:50 UTC, Basile B. wrote: On Sunday, 18 July 2021 at 17:45:05 UTC, Guillaume Piolat wrote: On Sunday, 18 July 2021 at 16:32:46 UTC, Basile B. wrote: [...] Thanks. Indeed that seems to work even when

Re: LLVM asm with constraints, and 2 operands

2021-07-18 Thread Basile B. via Digitalmars-d-learn
On Sunday, 18 July 2021 at 17:45:05 UTC, Guillaume Piolat wrote: On Sunday, 18 July 2021 at 16:32:46 UTC, Basile B. wrote: [...] Thanks. Indeed that seems to work even when inline and optimized. Registers are spilled to stack. A minor concern is what happens when the enclosing function is

Re: LLVM asm with constraints, and 2 operands

2021-07-18 Thread Basile B. via Digitalmars-d-learn
On Sunday, 18 July 2021 at 18:47:50 UTC, Basile B. wrote: On Sunday, 18 July 2021 at 17:45:05 UTC, Guillaume Piolat wrote: On Sunday, 18 July 2021 at 16:32:46 UTC, Basile B. wrote: [...] Thanks. Indeed that seems to work even when inline and optimized. Registers are spilled to stack. A

Re: Including a file

2021-07-18 Thread Ali Çehreli via Digitalmars-d-learn
On 7/18/21 10:28 AM, Vindex wrote: > ``` > ldc2 source/main.d -ofmyprogram -L-l:libmylib.so.0 > Error: file "thing.json" cannot be found or not in a path specified with -J > ``` > > Is the actual inclusion of the file on import deferred until the link step? I wonder whether it's an ldc

Re: Including a file

2021-07-18 Thread Vindex via Digitalmars-d-learn
On Sunday, 18 July 2021 at 17:31:24 UTC, Adam D Ruppe wrote: On Sunday, 18 July 2021 at 17:28:07 UTC, Vindex wrote: Error: file "thing.json" cannot be found or not in a path specified with -J You need to specify the path where it is found with the -J switch to the compiler. Like `ldc2 -J.

Re: LLVM asm with constraints, and 2 operands

2021-07-18 Thread Guillaume Piolat via Digitalmars-d-learn
On Sunday, 18 July 2021 at 16:32:46 UTC, Basile B. wrote: Yeah I can confirm it's aweful. Took me hours to understand how to use it a bit (my PL has [an interface](https://styx-lang.gitlab.io/styx/primary_expressions.html#asmexpression) for LLVM asm) You need to add a "x" to the constraint

Re: Including a file

2021-07-18 Thread Vindex via Digitalmars-d-learn
On Sunday, 18 July 2021 at 17:31:24 UTC, Adam D Ruppe wrote: On Sunday, 18 July 2021 at 17:28:07 UTC, Vindex wrote: Error: file "thing.json" cannot be found or not in a path specified with -J You need to specify the path where it is found with the -J switch to the compiler. Like `ldc2 -J.

Re: Including a file

2021-07-18 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 18 July 2021 at 17:28:07 UTC, Vindex wrote: Error: file "thing.json" cannot be found or not in a path specified with -J You need to specify the path where it is found with the -J switch to the compiler. Like `ldc2 -J. yourfile.d

Including a file

2021-07-18 Thread Vindex via Digitalmars-d-learn
One of my library modules (for example, libmylib) has the line `immutable string jsonText = import("thing.json")` When I try to build a program with this (already installed) library I see error ``` ldc2 source/main.d -ofmyprogram -L-l:libmylib.so.0 Error: file "thing.json" cannot be found

Re: LLVM asm with constraints, and 2 operands

2021-07-18 Thread Basile B. via Digitalmars-d-learn
On Sunday, 18 July 2021 at 11:42:24 UTC, Guillaume Piolat wrote: Is anyone versed in LLVM inline asm? I know how to generate SIMD unary op with: return __asm!int4("pmovsxwd $1,$0","=x,x",a); but I struggle to generate 2-operands SIMD ops like: return __asm!int4("paddd

Re: function parameters: is it possible to pass byref ... while being optional at the same time ?

2021-07-18 Thread someone via Digitalmars-d-learn
On Sunday, 18 July 2021 at 11:04:55 UTC, Adam D Ruppe wrote: On Sunday, 18 July 2021 at 03:52:30 UTC, someone wrote: That being said, one of the things that I felt in love with when I was first exposed to was OOP; with all its pros and cons. Yeah I like a lot about OOP and D's implementation

Re: interface function member declarations needing parameter attributes ?

2021-07-18 Thread someone via Digitalmars-d-learn
On Sunday, 18 July 2021 at 11:03:24 UTC, Adam D Ruppe wrote: Fun fact there: any child implementations do NOT need to specify the attribute there; the compiler will copy it from the interface for you. I suppose these are the day-to-day minor details you can rely on to avoid typing a lot of

Re: Creating immutable arrays in @safe code

2021-07-18 Thread zjh via Digitalmars-d-learn
On Sunday, 18 July 2021 at 10:02:07 UTC, ag0aep6g wrote: On 17.07.21 15:56, ag0aep6g wrote: +1. IMO,`strong pure` is `the outside world` has no impact on me. `Funcs` don't have any `indirect`.

LLVM asm with constraints, and 2 operands

2021-07-18 Thread Guillaume Piolat via Digitalmars-d-learn
Is anyone versed in LLVM inline asm? I know how to generate SIMD unary op with: return __asm!int4("pmovsxwd $1,$0","=x,x",a); but I struggle to generate 2-operands SIMD ops like: return __asm!int4("paddd $1,$0","=x,x",a, b); If you know how to do it =>

Re: interface function member declarations needing parameter attributes ?

2021-07-18 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 18 July 2021 at 03:27:04 UTC, someone wrote: I have an interface with function members *not* being declared @safe (at first glance it seemed irrelevant to me just to mark @safe a declaration and not an actual implementation). Yeah, that'd be promising all child implementations are

Re: function parameters: is it possible to pass byref ... while being optional at the same time ?

2021-07-18 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 18 July 2021 at 03:52:30 UTC, someone wrote: That being said, one of the things that I felt in love with when I was first exposed to was OOP; with all its pros and cons. Yeah I like a lot about OOP and D's implementation is one of the nicest out there. Very competent implementation

Re: Creating immutable arrays in @safe code

2021-07-18 Thread ag0aep6g via Digitalmars-d-learn
On 17.07.21 15:56, ag0aep6g wrote: At a glance, the only meaningful use of `PURE.strong` seems to be in dcast.d, introduced by the PR you linked. Changing that to `PURE.const_` doesn't break any tests for me. So I'm inclined to believe that `PURE.strong` is nonsense, and that `PURE.const_`