On Monday, 17 August 2020 at 14:43:27 UTC, H. S. Teoh wrote:
What you need is to create an overload of toString that takes a
FormatSpec parameter, so that you can decide what should be
output for which format spec. Something along these lines:
Sorry, i can't make it works.
I tried ti read
On Tuesday, 18 August 2020 at 05:54:16 UTC, H. S. Teoh wrote:
Here's a working example:
Thank you, it works!
DMD x86 on Windows have no dependencies, just unpack .zip and use.
It's a pitty, that DMD x64 depend on VS :(
Hello.
I have wrapping Windows API functions, wich return 0 on success
and erroro code on failure.
I copy wenforce template as:
```
private T denforce(T, S)(T value, lazy S msg = null, string file
= __FILE__, size_t line = __LINE__)
{
import core.sys.windows.winerror: NO_ERROR;
import
On Monday, 17 August 2020 at 08:55:49 UTC, Simen Kjærås wrote:
Take the function as an alias parameter and wrap the entire
call:
Simen, for some reasons, your code dont respect api arg with
"out" attribute.
For example, i have
```
extern (Windows)
DhcpEnumServers(
in DWORD
On Monday, 17 August 2020 at 10:11:29 UTC, MoonlightSentinel
wrote:
On Monday, 17 August 2020 at 09:59:21 UTC, novice3 wrote:
On Monday, 17 August 2020 at 09:45:55 UTC, novice3 wrote:
access violation occur.
reduced code https://run.dlang.io/is/U58t9R
The wrapper parameters don't inherit
On Monday, 17 August 2020 at 08:55:49 UTC, Simen Kjærås wrote:
Take the function as an alias parameter and wrap the entire
call:
auto denforce(alias fn, string file = __FILE__, size_t line =
__LINE__, Args...)(Args args)
Thank you, Simen!
On Monday, 17 August 2020 at 09:45:55 UTC, novice3 wrote:
access violation occur.
reduced code https://run.dlang.io/is/U58t9R
void test(out int x) { x = 42; }
void call (alias fn, Args ...)(Args args) { fn(args); }
void main(){
int a;
a = 111;
test(a);
assert(a == 42); //
Hello.
I need subtype uint to store ipv4 address.
It should be like ordinary uint,
except conversion to string with %s format.
My try https://run.dlang.io/is/fwTc0H failed on last assert:
```
struct IpV4Address
{
private uint ip;
alias ip this;
string toString()
{
import
Naive newbie question:
Can we have (in theory) in D lang memory management like V lang?
Quote:
https://github.com/vlang/v/blob/master/doc/docs.md#memory-management
"V doesn't use garbage collection or reference counting. The
compiler cleans everything up during compilation. If your V
Hello.
I don't use dub.
I use Windows and *.d file association to compile small apps by
dmd with "-i -unittest -g" switches.
Now i update dmd, and found, that apps compiled with "-unittest"
not runs main().
How i can restore old behaviour (run all unittests then main())
*without use
On Thursday, 13 August 2020 at 08:30:44 UTC, Jonathan wrote:
Is there a reason you need to run all unittests every time you
want to run the program?
App will be used by other peoples,
and i will release it after developing without unittests.
Release is rare action for me.
Running while
On Thursday, 13 August 2020 at 08:49:21 UTC, WebFreak001 wrote:
Try
version (unittest) extern(C) __gshared string[] rt_options =
["testmode=run-main" ];
Thanks! It works as needed.
On Thursday, 13 August 2020 at 08:30:44 UTC, Jonathan wrote:
Is there a reason you need to run all unittests every time you
want to run the program?
Starting app with unittests while develop - frequent event for me.
Releasing app - rare event for me.
I want do frequent action without efforts
On Thursday, 13 August 2020 at 09:02:28 UTC, Nils Lankila wrote:
programmatically, in a way it is already, but by calling
function
Better with compiler switch, may be...
On Thursday, 22 October 2020 at 11:04:53 UTC, Vino wrote:
class Connections
{
private Connection conn;
auto constr =
"host=localhost;port=3910;user=user;pwd=password#;db=testdb";
this.conn = new Connection(constr);
}
where Connections class constructor implemented?
Hello.
When i adapt C code, i see new type creation:
typedef void* Xobj;
Or code like this:
struct _Xobj;
typedef struct _Xobj *Xobj;
I want create derived type in D, found std.typecons.Typedef
template, and write:
alias Xobj = Typedef!(void*, (void*).init);
But compiler use long
On Thursday, 1 April 2021 at 12:07:17 UTC, WebFreak001 wrote:
You can add a custom init value if you want to allow one:
```d
enum Xobj : void* { init = null }
```
Thank you!
On Wednesday, 31 March 2021 at 12:09:33 UTC, Basile B. wrote:
yeah template instances are identified using the parameters
identifiers, then the alias is just a syntactic shortcut to
that, not producing a new symbol with a unique mangle...
so, no way to generate struct with parametrized name
On Tuesday, 30 March 2021 at 21:53:34 UTC, Basile B. wrote:
struct Typedef(TBase)
{
TBase payload;
alias payload this;
}
alias Xobj = Typedef!(void*);
This is how std.typecons.Typedef made, IMHO.
The problem is this code generate struct with name
"Typedef!(void*)",
then compiler show
https://run.dlang.io/is/p4NVp8
```d
void main()
{
import std.stdio: writefln;
string[] s = ["a", "b", "c"];
writefln("%(%s, %)", s);
}
```
output
```d
"a", "b", "c"
```
expected
```d
a, b, c
```
there is extra quotes, wich not present in firmat specifier.
is this bug, or i should
On Thursday, 15 April 2021 at 20:56:18 UTC, mw wrote:
In response to user input?
e.g. createObject(userInputString);
what if user enter "Cthulhu"?
if you say "i will check user input",
then you know list of possible inputs,
then you can use some compile-time technics.
if you dont know
Hello.
I want make binding for some CPP api.
I have .h file with enums like:
///
typedef enum {
SOMEAPI_PHASE_A = 91,
SOMEAPI_PHASE_B = 92,
SOMEAPI_PHASE_C = 93
} someapiPhase;
///
It used later in .cpp like:
func(SOMEAPI_PHASE_A);
I want .d file like this:
On Monday, 15 February 2021 at 14:03:26 UTC, Paul Backus wrote:
This will do most of it:
Thank you Paul!
Hello.
Need advice:
Is it possible analyze "debug" condition in template, obtained
from instantiation place?
Like we using __LINE__ ?
For example, i have template for logging:
```d
void logf(string func = __FUNCTION__, int line = __LINE__,
A...)(string fmt, A args)
{
// here i want
i want to eliminate "debug(func1)" and "debug(func2)" from code:
```d
debug = func1;// enable logging for func1
//debug = func2; // disable logging for func2
void func1()
{
...
debug(func1) logf("var1=%d", var1);
...
}
void func2()
{
...
debug(func2) logf("var1=%d",
26 matches
Mail list logo