On Friday, 26 April 2024 at 13:25:34 UTC, Salih Dincer wrote:
You have a 5-item data tuples as Tuple(1, 2, 3, [1, 3], 5) and
implement the sum (total = 15) with the least codes using the
sum() function of the language you are coding...
Let's start with D:
```d
import std.typecons : tuple;
im
On Sunday, 7 July 2024 at 14:49:52 UTC, Anonymouse wrote:
On Sunday, 7 July 2024 at 14:41:31 UTC, Andrey Zherikov wrote:
```d
import std.path;
// Error: no property `asNormaliedPath` for
`dirName("/sandbox/onlineapp.d")` of type `string`
auto p = __FILE_FULL_PATH__.dirName.asNormaliedPath;
``
On Wednesday, 30 March 2022 at 04:15:24 UTC, Paul Backus wrote:
Probably the easiest way is to split it into two functions
```d
void f()
{
version (foo)
fVersionFoo();
else
fDefault();
}
void fVersionFoo()
{
/* ... */
}
void fDefault()
{
/* ... */
}
```
Then yo
I want to migrate my library API from standalone function that
takes delegate as argument to a template member function that
takes delegate as a template parameter but compiler errors out.
Here is code example:
```d
import std.stdio;
template T(P)
{
static void f_new(alias func)()
{
On Tuesday, 19 April 2022 at 16:38:42 UTC, Steven Schveighoffer
wrote:
On 4/19/22 11:46 AM, Paul Backus wrote:
If you remove `static` from `f_new`, you get an error message
talking about this explicitly:
Interesting that `static` does anything there, since it's a
no-op.
-Steve
I put `stat
On Tuesday, 19 April 2022 at 18:18:26 UTC, Andrey Zherikov wrote:
Is there a way/workaround to achieve the desired behavior?
Those two bugs pointed above were reported in 2017 and 2011 (!)
which makes me think that they won't be fixed any time soon
(I'm not sure that they are actually the same
I get the same error even with just `struct`:
```d
struct S
{
static void f_new(alias func)()
{
func();
}
}
void f_new(alias func)()
{
func();
}
void f(FUNC)(FUNC func)
{
f_new!(() => func()); // works
// S.f_new!(() => func()); // doesn't work
}
```
On Tuesday, 19 April 2022 at 19:07:37 UTC, Ali Çehreli wrote:
On 4/19/22 11:18, Andrey Zherikov wrote:
> Is there a way/workaround to achieve the desired behavior?
Can you describe the goal a little more. For example, I assume
you really need a more useful lambda although the example you
show
On Tuesday, 19 April 2022 at 20:29:01 UTC, Steven Schveighoffer
wrote:
You can work around the dual context, if you are OK with
passing the second context explicitly.
The easiest way is to move the member function to a UFCS
function. an example:
```d
struct X
{
int x;
void applyToX(ali
Seems compiler allows custom nested type with `init` name:
```d
struct T
{
struct init {}
int b = 2;
}
void main()
{
T t;
writeln(t);// T(2)
//writeln(T.init); // Error: cannot pass type `init` as a
function argument
}
```
Is it a compiler issue so this shouldn't
On Friday, 29 April 2022 at 12:05:35 UTC, Dennis wrote:
On Friday, 29 April 2022 at 11:30:49 UTC, Andrey Zherikov wrote:
Is it a compiler issue so this shouldn't be allowed?
Members called `init` are in the process of being deprecated,
see:
https://github.com/dlang/dmd/pull/12512
That's n
How to fix this?
```d
struct S
{
string[] s;
}
auto foo(string[] s...) // Error: typesafe variadic function
parameter `s` of type `string[]` cannot be marked `return`
{
return S(s);
}
void main()
{
import std.stdio: writeln;
writeln(foo("Hello D"));
}
```
Th
On Tuesday, 24 May 2022 at 22:51:50 UTC, Adam Ruppe wrote:
On Tuesday, 24 May 2022 at 22:46:55 UTC, Andrey Zherikov wrote:
return S(s);
return S(s.dup);
The variadic lives in a temporary array that expires at the end
of the function. So copying it out to the GC lets it live on.
Yo
I have tightly coupled code which I'd like to decouple but I'm a
bit stuck.
For simplicity, I reduced the amount of code to something simple
to understand. So I have a struct `S` that has templated member
function that does something. On the other side I have delegate
holder `R` - this delegate
On Tuesday, 31 May 2022 at 21:53:17 UTC, Paul Backus wrote:
If you want compile-time polymorphism, three's no other way.
Yes, I want compile-time polymorphism.
```d
import std.stdio;
struct S
{
// function that should be called from delegate
void doSomething(T)(T value) { value.write
On Tuesday, 31 May 2022 at 22:34:41 UTC, Christian Köstlin wrote:
Would it help to not create the delegate in R's constructor,
but feed
the delegate into it (and create the delegate outside). This
would also resemble your description (R is a delegate holder)
more.
That's possible but the prob
On Tuesday, 31 May 2022 at 23:15:24 UTC, Andrey Zherikov wrote:
On Tuesday, 31 May 2022 at 21:53:17 UTC, Paul Backus wrote:
If you want compile-time polymorphism, three's no other way.
Yes, I want compile-time polymorphism.
In case if `S.doSomething` is NOT template function then the
proble
I have [pretty simple code in my
library](https://github.com/andrey-zherikov/argparse/blob/bug/source/argparse/help.d#L27-L47):
```d
alias CC = SumType!(AA,BB);
struct AA {}
struct BB
{
CC[] c;
}
private void ppp(T, Output)(auto ref Output output, in
CommandArguments!T cmd, in Config config
On Tuesday, 14 June 2022 at 21:44:48 UTC, Dukc wrote:
No idea. The functions seems indeed to be exactly the same, so
I assume this is a DMD bug. It cannot be a bug in
`std.sumtype`, since that would trigger in both of the
templates.
This definitely triggers some bug in DMD because this `priva
On Wednesday, 15 June 2022 at 07:38:36 UTC, JG wrote:
I tried to reproduce it but wasn't able (I guess it is some
interplay with the rest of your code):
I tried this first but got the same result as you. I think my
small library overheats DMD's template engine.
On Wednesday, 15 June 2022 at 09:21:28 UTC, user1234 wrote:
On Tuesday, 14 June 2022 at 13:39:12 UTC, Andrey Zherikov wrote:
I have [pretty simple code in my
library](https://github.com/andrey-
[Line (2)
produces](https://github.com/andrey-zherikov/argparse/runs/6880350900?check_suite_focus=tru
On Wednesday, 15 June 2022 at 09:24:35 UTC, Dukc wrote:
Now when I think of it, perhaps the fact that private
`printHelp` has the same name as the public `printHelp` is
somehow confusing dmd. If you try to rename the private
`printHelp` and it's call in the public one to something else,
you mi
On Wednesday, 15 June 2022 at 16:53:13 UTC, mw wrote:
Create a simple test case, file bug at:
https://issues.dlang.org/
I tried. No luck.
In the example below `func` changes its `const*` argument. Does
this violates D's constness?
```d
import std;
struct S
{
string s;
void delegate(string s) update;
}
void func(const S* s)
{
writeln(*s);
s.update("func");
writeln(*s);
}
void main()
{
auto s = S("test");
On Friday, 29 July 2022 at 22:09:47 UTC, pascal111 wrote:
I next code, we have a data type problem
"54.among(to!uint[10](y)).writeln;":
module main;
import std.stdio;
import std.string;
import std.conv;
import dcollect;
import std.math;
import std.algorithm;
int main(string[] args)
{
On Friday, 29 July 2022 at 22:16:26 UTC, H. S. Teoh wrote:
This totally makes sense. Thanks for explanation!
On Monday, 1 August 2022 at 14:15:31 UTC, pascal111 wrote:
We all know the strange syntax of lambda function within filter
algorithm like "auto r = chain(a, b).filter!(a => a > 0);".
TBH I don't find lambda syntax strange - it's pretty nice and
there are two forms (unlike in C++): short one (`
On Monday, 1 August 2022 at 23:35:13 UTC, pascal111 wrote:
I think this line needs explanation:
'''D
return FilterResult!(unaryFun!predicate, Range)(range);
'''
Create an object of type `FilterResult!(unaryFun!predicate,
Range)` by passing `range` to its ctor, then return that object.
On Wednesday, 10 August 2022 at 13:34:53 UTC, pascal111 wrote:
So, the program will be like this:
Is this clearer?
```d
import std.stdio;
import std.algorithm;
import std.range;
double getNumber()
{
double x;
write("Enter a number: ");
readf(" %s\n", &x);
writeln;
retur
On Wednesday, 10 August 2022 at 14:08:59 UTC, pascal111 wrote:
This version has modern features, it's 1) functional 2)
goto-less.
There is nothing modern ;-D
I have this simple code:
```d
struct U
{
auto ref func(int i)() { return this; }
}
void main()
{
{
alias type = typeof(U().func!0);
pragma(msg, type); // pure nothrow @nogc ref @safe U()
return
pragma(msg, is(type : U)); // false
auto u = U().func!0;
On Monday, 22 August 2022 at 05:25:50 UTC, Ali Çehreli wrote:
This is where the @property keyword makes a difference:
@property auto ref func(int i)() { return this; }
Now U().func!0 will be a call in your expression.
Is original `U().func!0` not a call?
But I think std.traits.ReturnType
On Monday, 22 August 2022 at 06:01:11 UTC, JG wrote:
Why not just change to:
alias type = typeof(U().func!0());
This is user's code and `U().func!0` is legit syntax.
On Monday, 22 August 2022 at 12:04:09 UTC, Paul Backus wrote:
On Monday, 22 August 2022 at 11:24:59 UTC, Andrey Zherikov
wrote:
On Monday, 22 August 2022 at 06:01:11 UTC, JG wrote:
Why not just change to:
alias type = typeof(U().func!0());
This is user's code and `U().func!0` is legit syntax.
But the question is still opened: why is `typeof(U().func!0)` not
the same as `typeof(U().func!0())`?
There is also inconsistency within UFCS - type depends on whether
function is a member or standalone (even if I replace `auto ref`
with `ref U`):
```d
struct U
{
ref U func(int i)() { ret
On Monday, 22 August 2022 at 15:15:22 UTC, Paul Backus wrote:
My first instinct is to say that this is the user's mistake.
UDAs are not evaluated like normal expressions, and anyone
using UDAs is going to have to learn that sooner or later.
My feeling was that UDA expression is just an express
On Monday, 22 August 2022 at 15:20:46 UTC, Paul Backus wrote:
On Monday, 22 August 2022 at 14:43:24 UTC, Andrey Zherikov
wrote:
But the question is still opened: why is `typeof(U().func!0)`
not the same as `typeof(U().func!0())`?
Probably because if it were the same, it would be completely
im
On Monday, 22 August 2022 at 16:42:50 UTC, Paul Backus wrote:
It's probably not worth completely changing your API design
just to work around this issue. Also, even if you do this, it
is still possible for a user to run into a same problem with a
member function of one of their own types; for e
On Monday, 22 August 2022 at 17:40:59 UTC, Andrey Zherikov wrote:
I'm providing a struct (`U` in examples above) with some API
and I'm looking for this struct as an UDA (through
`hasUDA`/`getUDAs`). And actually I already have a mix of
member-functions and free-functions in my API so it's gonna
I have bunch of `static assert(, )` in my
code and would like to validate that specific code triggers
specific assert by checking what `` is thrown.
Right now I do `static assert(!__traits(compiles, {
}));` but since `` might not compile due to many
different reasons, I might not be testing
On Friday, 9 September 2022 at 15:22:30 UTC, Ali Çehreli wrote:
I added and removed '&& false' to every 'static assert'
condition manually one by one. :/
It's not CI-friendly :(
Perhaps a new compiler switch can compile every 'static assert'
with an automatic 'false' and dump all their text t
On Saturday, 10 September 2022 at 10:39:12 UTC, Injeckt wrote:
server.d(29): Error: function `server.WndProc(void* hwnd, uint
message, uint wParam, int lParam)` is not callable using
argument types `()`
I think you need to get address of a function:
```d
wndclass.lpfnWndProc = &WndProc;
```
On Monday, 3 October 2022 at 18:09:05 UTC, Fausto wrote:
Hello all,
I am trying to rotate left an array.
I found a very basic way, and I am not sure if there is
something clever than this :) maybe using slices...
the external for represents how many times you are rotating (in
this case 2).
I
On Sunday, 23 October 2022 at 20:12:46 UTC, Hipreme wrote:
This will greatly reduce the number of import and dependencies
you need if you ever need to distribute a library.
Could you elaborate more on the benefit? Does it reduce
compilation time for dependency? If so then how much?
I have the following types (simplified version of my code):
```d
struct A
{
int[] i;
}
struct B
{
A[] a = [A.init];
}
```
This code:
```d
auto b1 = B.init;
b1.a[0].i ~= 1;
b1.a ~= A.init;
b1.a[0].i ~= 11;
b1.a[1].i ~= 12;
b1.writeln;
auto b2 = B();
b2.writ
On Tuesday, 25 October 2022 at 14:53:50 UTC, Adam D Ruppe wrote:
But just don't do this. Only basic values and immutable strings
are good to initialize this way. With the array or class
objects, you're liable to get some shared thing.
If you change this to be initialized in a constructor (whic
On Tuesday, 25 October 2022 at 14:53:50 UTC, Adam D Ruppe wrote:
On Tuesday, 25 October 2022 at 13:51:30 UTC, Andrey Zherikov
wrote:
A[] a = [A.init];
This is a problem - this is referring to a static array
instance, shared across all copies of B. You almost certainly
don't want this.
On Wednesday, 26 October 2022 at 04:40:17 UTC, Salih Dincer wrote:
On Tuesday, 25 October 2022 at 13:51:30 UTC, Andrey Zherikov
wrote:
Does the second piece of code shows a bug or my expectation is
not correct (and why if so)?
As a result, if this is a bug, Andrey has the right to report
it.
On Saturday, 12 November 2022 at 10:02:12 UTC, confuzzled wrote:
Why would I have to search for libcrypto, libminizip, libexpat,
and more that I haven't even figured out what library they are?
I thought those dependencies would already be linked into
libxlsxio_read.a which is a statically linke
On Saturday, 19 November 2022 at 04:13:33 UTC, []() {}() wrote:
oh. so i get it now. you have to refactor your class (change
member variable names and also do it in all places where they
are used througout the class. then add new methods, overloading
them in this way and that way, all because y
On Saturday, 19 November 2022 at 09:05:42 UTC, []() {}() wrote:
Once you refactor your class (creating actual private member
variables and creating getter/setter methods, you are almost
certainly going to break binary compatability, and when you
send your update compiler library to your custome
On Saturday, 19 November 2022 at 09:12:26 UTC, thebluepandabear
wrote:
That's the point many people have given here which is not
convincing him, even though it is quite great.
I think we all know the answer here 😂
IMHO you are both right :)
You are speaking about API compatibility, `[]() {}()
On Saturday, 19 November 2022 at 09:12:26 UTC, thebluepandabear
wrote:
That's the point many people have given here which is not
convincing him, even though it is quite great.
I think we all know the answer here 😂
IMHO you are both right :)
You are speaking about API compatibility, `[]() {}()
On Saturday, 19 November 2022 at 09:51:09 UTC, []() {}() wrote:
no. in C# it breaks ABI. that is why its not acceptable in my
team.
Every company works differently. Yours are using .net and (I
guess) ships dlls so you must care about ABI with existing
software. In my company we use static lin
On Saturday, 19 November 2022 at 09:49:18 UTC, thebluepandabear
wrote:
I am too dumb to know what ABI is
https://en.wikipedia.org/wiki/Application_binary_interface
On Saturday, 19 November 2022 at 10:17:19 UTC, []() {}() wrote:
On Saturday, 19 November 2022 at 09:51:09 UTC, []() {}() wrote:
...
no. in C# it breaks ABI. that is why its not acceptable in my
team.
of course that's not the reason we don't use public member
variables in classes.
the rea
I have this (very simplified) code:
```d
void foo(alias callback)()
{
callback!5;
}
static void print(int i)() { writeln(i); }
foo!print;
```
Is there a way to merge two last lines into one of a form like
`foo!(...something...)`?
Note that callback parameter must be compile-time parameter
On Sunday, 11 December 2022 at 16:24:30 UTC, Ali Çehreli wrote:
On 12/11/22 05:54, Salih Dincer wrote:
> On Sunday, 11 December 2022 at 09:43:34 UTC, Andrey Zherikov
wrote:
>> Note that callback parameter must be compile-time parameter
as it
>> represents a member of a type during introspection d
On Monday, 2 October 2023 at 18:46:14 UTC, christian.koestlin
wrote:
On Monday, 2 October 2023 at 02:47:37 UTC, Joel wrote:
How can I improve this code? Like avoiding using foreach.
You could fold into a hash that counts the occurrences like
that:
```d
import std.uni : toLower;
import std.a
On Tuesday, 3 October 2023 at 19:57:06 UTC, christian.koestlin
wrote:
On Tuesday, 3 October 2023 at 01:55:43 UTC, Andrey Zherikov
wrote:
On Monday, 2 October 2023 at 18:46:14 UTC, christian.koestlin
wrote:
[...]
Slightly improved:
```d
import std;
[...]
Thanks .. the thing with ref result
On Thursday, 2 November 2023 at 19:43:01 UTC, Adam D Ruppe wrote:
On Thursday, 2 November 2023 at 19:30:58 UTC, Jonathan M Davis
wrote:
The entire reason that it was added to the language was to be
able to split up existing modules without breaking code. And
it does that well.
No, it doesn't
On Friday, 3 November 2023 at 00:52:18 UTC, H. S. Teoh wrote:
Supposedly you can do this:
/* Original: */
// pkg/mymodule.d
module mymodule;
... // code here
// main.d
import mymodule;
void main() { ... }
/* Split */
//
On Friday, 3 November 2023 at 18:04:58 UTC, Jonathan M Davis
wrote:
- Jonathan M Davis
Thanks a lot for detailed explanation!
On Friday, 3 November 2023 at 19:21:42 UTC, BoQsc wrote:
However I would want to try to enforce this behaviour from the
`dub.json` or `dub.sdl` file.
IMHO this is not something that should be enforced from package
build configuration, however there can be a way to configure it
on system level
On Sunday, 5 November 2023 at 18:36:40 UTC, Ctn-Dev wrote:
Is there a more concise way of getting the same result?
Try this:
```d
switch(range.map!(_ => (_== "Two" ? 2 : _=="One" ? 1 :
0)).fold!((a,b) => a | b)(0)) {
case 3: writeln("both"); break;
case 2: writein("only two"); break;
case 1:
Is there a way to check whether some module, say "foo", is
available for import before doing "import foo"?
I want to create a function that imports module if it's available
or does something else otherwise. So I think the code should look
something like this:
mixin template my_import(alias mod
On Friday, 26 July 2019 at 06:24:18 UTC, evilrat wrote:
On Friday, 26 July 2019 at 03:42:58 UTC, Andrey Zherikov wrote:
Is there a way to check whether some module, say "foo", is
available for import before doing "import foo"?
I did some really retarded utility like this in the past,
worked f
On Friday, 26 July 2019 at 14:14:11 UTC, Anonymouse wrote:
I use __traits(compiles, __traits(identifier, moduleName)) now
instead and it seems to work.
I couldn't find "identifier" docs on
https://dlang.org/phobos/std_traits.html. But I tried and it
doesn't work - I think because is unknown
On Friday, 26 July 2019 at 14:19:05 UTC, Paul Backus wrote:
version(HasStdio)
import std.stdio;
else
pragma(msg, "std.stdio is not available");
Then configure your build system to pass `-version=HasStdio` to
dmd (or the equivalent flag to ldc or gdc) when std.stdio is
available.
I wa
I want my program to add some directories into module lookup
process (like adding -I dmd options). List of directories is
known at compile time but the choice of what exact directories to
add depends on `-version` parameter.
Is there a way to achieve this in code?
I can actually do this by cre
On Wednesday, 31 July 2019 at 17:59:00 UTC, bauss wrote:
Your best bet is actually not relying on CTFE since IO is very
restricted at CTFE in D.
Ex. you can only import files that are specified by you.
The best thing you can do is have a file that lists every file
you need to be able to read
I found a function that seems could be used for adding import
paths: dmd.frontend.addImport
(https://dlang.org/phobos/dmd_frontend.html#.addImport). But it's
not clear how can I use it: dmd directory is not added to lookup
by default and trying adding it gives errors:
dmd.exe -i -Ic:\D\dmd-2
On Wednesday, 31 July 2019 at 20:16:01 UTC, H. S. Teoh wrote:
On Wed, Jul 31, 2019 at 08:09:29PM +, Andrey Zherikov via
Digitalmars-d-learn wrote:
I found a function that seems could be used for adding import
paths: dmd.frontend.addImport
(https://dlang.org/phobos/dmd_frontend.html
I have the following code:
// lib1/lib.d
module lib;
import std.stdio;
static this()
{
writeln("+" ~ __FILE__);
}
static ~this()
{
writeln("-" ~ __FILE__);
}
// main.d
int main()
{
import std.stdio;
writeln("hello");
return 0;
}
So if I compile lib.d and main.d together t
On Thursday, 8 August 2019 at 16:04:33 UTC, a11e99z wrote:
On Thursday, 8 August 2019 at 14:55:37 UTC, Andrey Zherikov
wrote:
I have the following code:
// main.d
int main()
{
import std.stdio;
writeln("hello");
return 0;
}
But if I create library from lib.d first and then link it
Here is the code I have which doesn't work:
```
string[] foo;
string[] bar;
auto args = ["app", "--bar", "bar", "--foo", "foo"]; // (1)
import std.getopt;
getopt(args,
std.getopt.config.stopOnFirstNonOption, // (2)
"foo", &foo,
"bar", &bar);
```
The error I s
I'm trying to write multi-threaded code that uses mutexes,
condition variables and atomics but I've got confused how to do
this correctly. Everything I found so far include a lot of
casting to/from shared even for the objects that are supposed to
be shared (like mutex and condition variable).
How can I get __FILE__ and __LINE__ values correct in case of
import expression?
Below is my test code.
/
test.d:
module test;
import std.stdio;
void test(string file = __FILE__, size_t line = __LINE__,
string mod = __MODULE__, string func = __FU
On Friday, 21 August 2020 at 15:27:14 UTC, Adam D. Ruppe wrote:
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
On Friday, 21 August 2020 at 15:34:49 UTC, Steven Schveighoffer
wrote:
On 8/21/20 10:01 AM, Andrey Zherikov wrote:
How can I get __FILE__ and __LINE__ values correct in case of
import expression?
...
So the output from line #16 (1) is correct although from line
#17 (2) is not: file name i
On Friday, 21 August 2020 at 20:44:27 UTC, Andrey Zherikov wrote:
Thanks for this link! I can use "#line" to fix line number but
not file name:
file: 'foo.d-mixin-1', line: '6', module: 'test',
function: 'test.main', pretty function: 'int test.main(string[]
args)',
file full path: 'C:\Users\a
On Saturday, 22 August 2020 at 03:43:10 UTC, Steven Schveighoffer
wrote:
On 8/21/20 6:34 PM, Adam D. Ruppe wrote:
On Friday, 21 August 2020 at 22:12:48 UTC, Steven
Schveighoffer wrote:
And honestly, if it says the source is "mixin-50, line 1", I
think people will get it.
I could probably live
On Friday, 21 August 2020 at 22:34:49 UTC, Adam D. Ruppe wrote:
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/ar
On a low level, I want something like this code to work:
string[] arr; // this can be any suitable type
arr ~= "a";// data is compile-time constant
enum f = arr[0]; // fails with "Error: variable arr cannot
be read at compile time"
enum b = arr[$-1]; // fails with
On Monday, 31 August 2020 at 20:44:16 UTC, Adam D. Ruppe wrote:
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 whate
On Tuesday, 1 September 2020 at 18:57:30 UTC, Steven
Schveighoffer wrote:
string overrideState(string s)
{
// work your magic here, it's normal D code!
}
void foo(string s)()
{
mixin(overrideState(s));
}
Unfortunately this won't work if there is a function 'bar' in
different module that
On Tuesday, 1 September 2020 at 18:19:55 UTC, Andrey Zherikov
wrote:
The thing I'm trying to implement is: I have a function
foo(string s)() and some "state"; this function should override
this "state" (using "s" param) for all code within this
function (note that code can execute other modules
On Tuesday, 1 September 2020 at 19:38:29 UTC, Steven
Schveighoffer wrote:
On 9/1/20 3:09 PM, Andrey Zherikov wrote:
Unfortunately this won't work if there is a function 'bar' in
different module that calls 'foo':
You should post a full example you expect to work or not work,
then we can discu
My code (test.d):
===
void main()
{
import std.path: buildPath;
pragma(msg, import("file"));
pragma(msg, import(buildPath(".", "file")));
}
===
Content of file "file" is one line with "hello" text.
Running command: dmd -J. -run test.d
Result on Ubuntu:
===
hello
hello
Adding some verbosity:
pragma(msg, import("file"));
pragma(msg, buildPath(".", "file"));
pragma(msg, import(buildPath(".", "file")));
Result on Ubuntu:
===
hello
./file
hello
===
Result on Windows:
===
hello
.\file
parser.d(47): Error: file ".\\file" cannot be found o
On Wednesday, 2 September 2020 at 14:38:30 UTC, Steven
Schveighoffer wrote:
Here is what I would do instead:
Thanks, I'll try it.
On Wednesday, 2 September 2020 at 17:40:55 UTC, Andrey Zherikov
wrote:
On Wednesday, 2 September 2020 at 14:38:30 UTC, Steven
Schveighoffer wrote:
Here is what I would do instead:
Thanks, I'll try it.
This actually works! Thanks a lot!
On Wednesday, 2 September 2020 at 17:47:47 UTC, Adam D. Ruppe
wrote:
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 com
On Wednesday, 2 September 2020 at 20:23:15 UTC, Steven
Schveighoffer wrote:
What I'm wondering is if it needs to be ./file instead of
.\file. Can you hard code that and see if it works?
This actually works:
pragma(msg, import("file"));
pragma(msg, buildPath(".", "file"));
pragma(msg
On Wednesday, 2 September 2020 at 19:13:47 UTC, Adam D. Ruppe
wrote:
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
On Wednesday, 2 September 2020 at 20:55:34 UTC, Andrey Zherikov
wrote:
I think the issue is here:
https://github.com/dlang/dmd/blob/master/src/dmd/root/filename.d#L736-L748
Yes, issue is there. This change (removal of "c == '\\' || ")
fixes it:
diff --git a/src/dmd/root/filename.d b/src/dmd/
I have this code:
==
class S
{
int i = -1;
this(int n) { i = n; writeln(i," ",__PRETTY_FUNCTION__); }
~this() { writeln(i," ",__PRETTY_FUNCTION__); }
}
auto create()
{
writeln("-> ",__PRETTY_FUNCTION__);
scope(exit) writeln("<- ",__PRETTY_FUNCTION__);
return sco
On Friday, 18 September 2020 at 10:54:41 UTC, ikod wrote:
On Friday, 18 September 2020 at 10:43:47 UTC, Andrey Zherikov
wrote:
I have this code:
==
class S
...
auto create()
{
writeln("-> ",__PRETTY_FUNCTION__);
scope(exit) writeln("<- ",__PRETTY_FUNCTION__);
return scop
On Friday, 18 September 2020 at 11:31:39 UTC, Simen Kjærås wrote:
On Friday, 18 September 2020 at 10:43:47 UTC, Andrey Zherikov
wrote:
Why is dtor called before returning from do_lazy function -
see (1)? It seems cause uninitialized parameter in
do_something call after it in (2)-(3).
As ikod
On Friday, 18 September 2020 at 13:28:39 UTC, Simen Kjærås wrote:
Indeed. As we can see from the output, first do_lazy() is
called from test.main, then create() is called (this happens
inside do_lazy, as s is lazy). When create() returns, the
scoped!S you created goes out of scope and is destro
1 - 100 of 168 matches
Mail list logo