On Tuesday, 24 November 2015 at 14:23:38 UTC, Steven
Schveighoffer wrote:
If CTFE associative arrays perform differently, then that is a
bug. I am not sure if this is the case, but you should file a
bug anyway, someone can take a look at it.
If you can narrow it down to a minimal case where
On Tuesday, 24 November 2015 at 07:54:24 UTC, Bastiaan Veelo
wrote:
This results TRUE at compile time, but FALSE at run time.
Sorry, that should be the reverse: TRUE at run time, FALSE at
compile time. Compile time exhibits the unexpected behaviour.
Pegged uses an associative array to prevent infinite recursion
[1]. This fails on some input, but only when used in CTFE [2].
The reduced case follows. I presume this is a bug?
[1]
https://github.com/PhilippeSigaud/Pegged/blob/master/pegged/dev/introspection.d#L281
[2]
On Monday, 15 February 2016 at 01:14:10 UTC, Ali Çehreli wrote:
On 02/14/2016 11:32 AM, Bastiaan Veelo wrote:
If it's acceptable for you, the following code calls .save on
the elements and it works:
import std.algorithm.iteration;
import std.stdio;
import std.array;// <-- ADDED
void
On Monday, 15 February 2016 at 01:42:30 UTC, Mike Parker wrote:
On Sunday, 14 February 2016 at 19:32:31 UTC, Bastiaan Veelo
wrote:
Maybe this [1] will help shed some light.
[1] https://www.packtpub.com/books/content/understanding-ranges
Good idea. I have your book, but it is very nice to
On Monday, 15 February 2016 at 18:13:48 UTC, Ali Çehreli wrote:
On 02/15/2016 06:25 AM, Bastiaan Veelo wrote:
> I didn't even know about save... Its documentation is hidden
> quite
> well, because I still cannot find it.
Heh. :) It is a part of the ForwardRange interface (more
correctly,
On Sunday, 14 February 2016 at 18:28:11 UTC, Jonathan M Davis
wrote:
An immutable range fundamentally does not work. The same goes
with const. In fact, a type that's immutable is going to fail
isInputRange precisely because it can't possibly function as
one. While empty and front may be
Hi,
I am having trouble getting the iteration methods in
std.algorithm.iteration to work on immutable data:
import std.algorithm.iteration;
import std.stdio;
void main()
{
string[][] cycles;
cycles ~= ["one", "two"];
cycles ~= ["three", "four"];
foreach
On Monday, 6 February 2017 at 23:42:55 UTC, Ali Çehreli wrote:
Then you use _ptr when indexing:
// Support e = arr[5];
ref T opIndex(ptrdiff_t index) {
assert(index >= first);
assert(index <= last);
return *(_ptr + index);
}
Ali
Thank you very much for
On Tuesday, 7 February 2017 at 20:28:30 UTC, Ali Çehreli wrote:
You forgot to call that most important function. ;)
Hah of course. I assumed the name would give it some special
meaning, like postblit.
1) I don't understand the first assert there, which does not
pass for me, so I commented
On Tuesday, 7 February 2017 at 20:33:35 UTC, Ali Çehreli wrote:
On 02/07/2017 02:11 AM, Bastiaan Veelo wrote:
> We do not need to take measures against the GC?
Of course we have to and the struct that I wrote is illegal
because it is self-referencing through the _ptr member. (D has
the right
On Tuesday, 4 August 2015 at 08:18:50 UTC, Marc Schütz wrote:
void opIndexAssign(U : T)(size_t index, auto ref U
value) {
Careful here, you've got the arguments reversed. The unit test
didn't detect this because it was ambiguous. This one isn't:
unittest {
On Monday, 6 February 2017 at 14:26:35 UTC, Bastiaan Veelo wrote:
The unit test didn't detect this because it was ambiguous.
Sorry for that misinformation. I should have said that
opIndexAssign wasn't tested. Here is a better test.
unittest {
OneBasedArray!int arr;
arr =
(There is an honest question in the end, please read on.)
All good reasons set aside, both in favour and against 0-based
arrays, the only reason that is relevant to me right now is that
we are seriously looking into translating close to a million
lines of foreign code to D, from a language
Wrapup: I am going to go for the original approach of index
conversion, and leaving the offset-pointer approach for what it
is.
Reasons:
1) uncertain efficiency gain/loss,
2) theoretically it may fail,
3) .sizeof does not include the payload,
4) analysis of the assembler generated by our
Thanks again.
On Tuesday, 14 February 2017 at 14:08:31 UTC, John Colvin wrote:
I would recommend making `template from(string moduleName)`
global (maybe in a utils module?), there's no reason for it to
be a member of Initial.
Yes, I think there is high chance it will be part of Phobos, if
On Monday, 13 February 2017 at 16:40:02 UTC, Daniel Kozak wrote:
https://dlang.org/phobos/std_typecons.html#.Typedef
Thanks for the pointers. Both Typedef and Proxy create types that
don't mix with the base type, which I want to the contrary. So I
guess I'll go with
struct Initial(T, T
On Monday, 13 February 2017 at 22:59:11 UTC, John Colvin wrote:
Why not use a constructor instead of static opCall?
I don't know, this comes from
http://dlang.org/spec/struct.html#dynamic_struct_init. Your
constructor looks a lot better. Am I missing a test case where
static opCall would be
On Tuesday, 14 February 2017 at 01:31:10 UTC, John Colvin wrote:
On Monday, 13 February 2017 at 22:59:11 UTC, John Colvin wrote:
[ snip ]
sorry, made a typo, that should have been
alias int1 = Initial!(int, 1);
static assert(int1.initial == 1); // typeof(int1.initial)
== int
Hi,
In Extended Pascal, you can derive from a basic type and change
the default initialiser like so:
type int1 = integer value 1;
var i : int1;
ii : int1 value 2;
assert(i = 1);
assert(ii = 2);
I have it working in D, but it seems a little clumsy. Is there a
better way?
// enum int maxarray = 0;
enum int maxarray = 2_000_000;
double[maxarray] a, b, c, d;
void main() {}
Compiled using "dub build --arch=x86_64 --build=release" on
Windows (DMD32 D Compiler v2.073.0), the exe size is 302_592
bytes v.s. 64_302_592 bytes, depending on the array length.
Is that
On Friday, 10 February 2017 at 12:58:19 UTC, Stefan Koch wrote:
If you want it to modify the array you have to use a ref elem.
If you do you will see that foreach is a little slower.
Thanks, I should have spotted that.
Bastiaan.
On Friday, 10 February 2017 at 12:57:38 UTC, biozic wrote:
On Friday, 10 February 2017 at 12:39:50 UTC, Bastiaan Veelo
wrote:
void foreach_loop()
{
foreach(n, elem; d[])
elem = a[n] * b[n] / c[n];
}
It's fast because the result of the operation (elem) is
Benchmarking for() against foreach():
/
enum size_t maxarray = 500_000;
double[maxarray] a, b, c, d;
void main()
{
import std.stdio;
import std.datetime;
import std.random;
for (int n = 0; n < maxarray; n++)
{
a[n] = uniform01;
b[n] = uniform01;
On Saturday, 11 February 2017 at 00:16:04 UTC, sarn wrote:
If you explicitly initialise the array to all 0.0, you should
see it disappear from the binary.
I was actually wondering whether initialisation would make a
difference, so thank you for this.
Bastiaan.
Thanks for the clarifications.
On Monday, 27 February 2017 at 11:53:09 UTC, ag0aep6g wrote:
You can generate wrapper functions that have no overloads:
static int wrap(alias f)(int arg) { return f(arg); }
enum addrOf(alias f) =
enum fptrs = staticMap!(addrOf, staticMap!(wrap, funcs));
/* ... r and foreach as before ...
On Monday, 27 February 2017 at 02:02:57 UTC, ag0aep6g wrote:
Make a range or an array of function pointers from the AliasSeq
of function aliases:
import std.meta: staticMap;
import std.range: only;
enum fptr(alias f) =
enum fptrs = staticMap!(fptr, funcs);
auto r = only(fptrs);
foreach
Hi,
Is it possible to parallelise the iteration over an AliasSec?
Ordinary parallel foreach does not work. I have tried submitting
tasks to taskPool in an ordinary foreach, but I can't because i
cannot be read at compile time.
int one(int) {return 1;}
int two(int) {return 2;}
int three(int)
On Monday, 27 February 2017 at 02:02:57 UTC, ag0aep6g wrote:
Make a range or an array of function pointers from the AliasSeq
of function aliases:
import std.meta: staticMap;
import std.range: only;
enum fptr(alias f) =
enum fptrs = staticMap!(fptr, funcs);
auto r = only(fptrs);
foreach
On Monday, 27 February 2017 at 16:04:00 UTC, Bastiaan Veelo wrote:
I get a bus error some time out in execution.
It could be that I am running out of stack space. I am on OS X,
and non-main threads are given a very limited stack size, they
say [1, 2]. This foreach of mine calls into itself,
Hi,
I am having trouble explaining the following to someone learning
D. Can someone explain why readln has different behaviour when it
is preceded by readf?
Suppose we want to not end the program before the user presses
Enter by having readln at the end of main():
```
import std.stdio;
On Thursday, 27 April 2017 at 08:37:26 UTC, ketmar wrote:
Bastiaan Veelo wrote:
Hi,
I am having trouble explaining the following to someone
learning D. Can someone explain why readln has different
behaviour when it is preceded by readf?
Suppose we want to not end the program before the
On Sunday, 6 August 2017 at 23:44:27 UTC, greatsam4sure wrote:
Good day. I will appreciate it if anybody here can help me with
the step by step way of installing ldc D compiler on windows. I
have read online info but i just don't get it. let the process
be in steps for easy
On Sunday, 6 August 2017 at 16:47:14 UTC, holo wrote:
Hello
I'm trying to use auth framework with REST api (
http://vibed.org/api/vibe.web.auth/ ).
Is it possible to use it with registerRestInterface? According
to description under:
http://vibed.org/api/vibe.web.auth/requiresAuth it should
On Friday, 12 May 2017 at 11:10:01 UTC, k-five wrote:
I was waiting for a stable version of C++17 ( standard library
) to add some features of fileSystem in C++17 to my program
that wants to iterate through all files in a directory
recursively.
I was thinking how could I do for implementing
On Saturday, 13 May 2017 at 08:23:55 UTC, k-five wrote:
On Friday, 12 May 2017 at 20:53:56 UTC, Bastiaan Veelo wrote:
Is it safe to say that these 40 lines of D do the same as your
324 lines of C++ [1]?
No. I cannot say that.
Since this is not a full port of renrem in C++ to D. It was
just
On Saturday, 13 May 2017 at 10:51:09 UTC, k-five wrote:
Okay, and NOW I understood what you are trying to say.
First of all I thought you got mad at me. And I became sad.
My sincere apologies! Always assume the best in people :-) I am
glad you asked for clarification.
[...] Still I am a
On Saturday, 13 May 2017 at 09:51:40 UTC, k-five wrote:
On Saturday, 13 May 2017 at 09:05:17 UTC, Jonathan M Davis
But obviously, to know what's actually happening with your
code, you're going to have to profile and benchmark it -
Can you please give a link or page or something to read about
On Friday, 12 May 2017 at 15:24:52 UTC, k-five wrote:
On Friday, 12 May 2017 at 11:10:01 UTC, k-five wrote:
I was waiting for a stable version of C++17 ( standard library
) to add some features of fileSystem in C++17 to my program
that wants to iterate through all files in a directory
On Friday, 12 May 2017 at 15:24:52 UTC, k-five wrote:
A full version that I just added to my gitgub:
https://github.com/k-five/dren
You may like getopt[1] for command line argument parsing.
https://dlang.org/phobos/std_getopt.html
`
void main()
{
import std.stdio;
struct S
{
int i;
union
{
int a;
double b;
}
}
S s;
writeln(s); // S(10, #{overlap a,
On Monday, 22 May 2017 at 22:11:15 UTC, Stanislav Blinov wrote:
On Monday, 22 May 2017 at 21:03:42 UTC, Bastiaan Veelo wrote:
Is there a way to detect at CT that S has overlapping data
members, when an anonimous union is used as above?
There isn't a built-in one. The best I can muster at
On Tuesday, 23 May 2017 at 01:02:59 UTC, Vladimir Panteleev wrote:
On Monday, 22 May 2017 at 21:03:42 UTC, Bastiaan Veelo wrote:
Is there a way to detect at CT that S has overlapping data
members, when an anonimous union is used as above?
I have an implementation here:
On Thursday, 14 December 2017 at 03:17:10 UTC, rikki cattermole
wrote:
On 14/12/2017 3:16 AM, n00nb wrote:
I don't understand if there is a way to generate documentation
for all the members without putting a '///' over every member
There isn't.
It doesn’t need to take any vertical space
On Friday, 10 November 2017 at 10:12:32 UTC, RazvanN wrote:
I don't want to open a new forum thread for this, but if you
guys have more experience with ddox can you please explain me
how does it work? I expected you can simply run ddox on a .d
file and it will output the documentation in some
Hi,
Context: https://github.com/veelo/Pascal2D
One of my source files is generated by executing `cd source &&
rdmd generate.d`, which creates the file `source/epparser.d`.
(There is actually one step in between, calling `rdmd make.d`,
which checks creation times, but that's not relevant
Hi!
The code in [1] compiles and runs flawlessly on Windows, but not
on Linux (neither run.dlang nor Travis docker image). Any idea
what can be done?
errors:
Error: undefined identifier __va_list_tag
onlineapp.d(282): Error: template instance
`onlineapp.SetFactory!byte` error instantiating
On Thursday, 17 May 2018 at 17:42:21 UTC, Bastiaan Veelo wrote:
Isn't preGenerateCommands meant to cover this case?
Appears to be a bug. Filed
https://github.com/dlang/dub/issues/1474
On Thursday, 17 May 2018 at 23:18:32 UTC, Basile B. wrote:
On Thursday, 17 May 2018 at 22:07:46 UTC, Bastiaan Veelo wrote:
Hi!
The code in [1] compiles and runs flawlessly on Windows, but
not on Linux (neither run.dlang nor Travis docker image). Any
idea what can be done?
Hello. Yes, add
Writing a single value to binary file can be done in (at least)
two ways. Let `f` be a `File`:
```
f.rawWrite(()[0 .. 1]);
```
or
```
f.lockingBinaryWriter.put(value);
```
The former way is little talked about, the latter is not even
documented. As far as I can see, the latter resolves to
On Monday, 18 June 2018 at 17:58:11 UTC, Steven Schveighoffer
wrote:
On 6/18/18 1:25 PM, bauss wrote:
On Monday, 18 June 2018 at 17:16:29 UTC, aliak wrote:
On Monday, 18 June 2018 at 14:19:30 UTC, Steven Schveighoffer
wrote:
On 6/18/18 7:16 AM, Bastiaan Veelo wrote:
On Sunday, 18 May 2014 at
On Sunday, 18 May 2014 at 08:15:08 UTC, Steffen Wenz wrote:
Hi,
Just noticed that using UFCS does not work for nested
functions, and was wondering whether that's intended, and what
the rationale behind it is:
I just had the same question.
I can imagine that the context pointer of nested
On Monday, 18 June 2018 at 19:31:39 UTC, Steven Schveighoffer
wrote:
In other words, if UFCS meant that module-level symbols took
precedent over local symbols, then it's backwards in terms of
which place usually wins. Generally it's the local symbols.
Ah, you mean it would have to be that way
I need some help understanding where extra '\r' come from when
output is redirected to file on Windows.
First, this works correctly:
rdmd --eval="(\"hello\" ~ newline).toFile(\"out.txt\");"
As expected, out.txt contains "hello\r\n".
I would expect the following to do the same, but it doesn't:
On Sunday, 3 June 2018 at 15:42:48 UTC, rikki cattermole wrote:
On 04/06/2018 3:24 AM, Bastiaan Veelo wrote:
I need some help understanding where extra '\r' come from when
output is redirected to file on Windows.
First, this works correctly:
rdmd --eval="(\"hello\" ~
On Monday, 4 June 2018 at 15:31:04 UTC, Steven Schveighoffer
wrote:
Windows C library has this bizarro mode for FILE * called
"text" mode, which is the default. In this mode, it scans all
output, and anywhere it sees a '\n', it replaces it with "\r\n".
Thanks, Steven.
I suppose the following is not a bug, but confusing it is:
```
void main()
{
import std.stdio;
import std.bitmanip;
BitArray ba = [1, 1, 1, 1, 1, 1, 1, 1];
writeln(ba);// [1, 1, 1, 1, 1, 1, 1, 1]
ba >>= 4; // right shift
writeln(ba);// [1, 1,
Hi,
One of my source files (epparser.d) should be generated by
calling rdmd on another soure file (make.d) and therefore should
depend on changes in make.d and an additional module
(epgrammar.d). An include path to Pegged is required for
compilation. epparser.d should be part of the main
On Saturday, 6 January 2018 at 13:40:54 UTC, rikki cattermole
wrote:
On 06/01/2018 1:23 PM, Bastiaan Veelo wrote:
Can dub do this or is this a thing for reggae? It must work on
Windows though.
Thanks!
See: https://github.com/Abscissa/gen-package-version
That seems to be a good tip,
On Saturday, 6 January 2018 at 13:40:54 UTC, rikki cattermole
wrote:
On 06/01/2018 1:23 PM, Bastiaan Veelo wrote:
I could script a custom preBuildCommand that checks
modification dates and supplies the Pegged include path
explicitly but that seems hackish and non-portable and
typically
On Sunday, 7 January 2018 at 13:50:23 UTC, Adam D. Ruppe wrote:
On Sunday, 7 January 2018 at 12:40:22 UTC, Bastiaan Veelo wrote:
1) Should we have a reference in the docs for std.traits to
std.range.primitive : ElementType?
wouldn't hurt i guess
2) Should phobos contain a version without the
The learn forum is great not only for asking questions, but also
for learning from the questions by others: I just learned about
the existence of std.range.primitives: ElementType, a function
that I have looked for in phobos before, without finding it. I
had expected this to be in std.traits
On Wednesday, 24 January 2018 at 14:21:42 UTC, ag0aep6g wrote:
The spec says that you cannot make an overload set just by
mixing in multiple functions/methods with the same name.
Instead, you have to do it like this:
mixin getter g;
mixin setter!int s;
alias p = g.p;
alias p = s.p;
On Tuesday, 6 February 2018 at 22:36:09 UTC, WhatMeWorry wrote:
https://www.khronos.org/opengl/wiki/Language_bindings
I was thinking that with derelictGL, D should be on this list?
If so, I'm not sure how one would go about this?
It is a wiki, anybody can add it, me thinks.
On Friday, 2 February 2018 at 00:33:03 UTC, Jakub Łabaj wrote:
On the other hand, shifting operators are equally confusing for
me, as they are for you - they really work in the other way
around! I thought this is a very weird bug, but I found this
pull request:
On Wednesday, 27 December 2017 at 20:45:49 UTC, Biotronic wrote:
BitArray is apparently a mess.
Thanks for your confirmation, digging and reporting issues
https://issues.dlang.org/show_bug.cgi?id=18133 and
https://issues.dlang.org/show_bug.cgi?id=18134
(Turns out we both live in the same
On Monday, 30 July 2018 at 01:50:23 UTC, CC wrote:
[...]
My usual modus operandi is:
1. check out the project into some directory "foo".
2. create another directory "foo.build", somewhere outside of
"foo".
3. "cd foo.build"
4. Run some configuration script/file located in "foo", to
generate
On Tuesday, 19 December 2017 at 10:15:18 UTC, Jacob Carlborg
wrote:
On 2017-12-18 23:36, WhatMeWorry wrote:
[...]
But when I look the directory that has the dub.sdl file, I
also see a file called dub.selections.json
{
"fileVersion": 1,
"versions": {
"derelict-al":
On Saturday, 4 August 2018 at 17:53:45 UTC, Neia Neutuladh wrote:
On Friday, 3 August 2018 at 19:41:32 UTC, Bastiaan Veelo wrote:
But if you commit it, and a compiler deprecation causes a
dependency in that pinned version to fail to compile, then
your app won't compile either, even though your
Hi,
`Alias this` to mixed in properties does not seem to work, see
below. If you think it should, I'll file an issue. Otherwise: can
this be made to work somehow?
Interestingly, if you uncomment either the mixin getter or setter
(row 36 or 37) and its corresponding use in `main`, then the
Currently, BitArray is not usable at compile time, so you cannot
do
```
enum e = BitArray([1, 1, 1, 0]);
```
This gives
/dlang/dmd/linux/bin64/../../src/phobos/std/bitmanip.d(1190):
Error: `bts` cannot be interpreted at compile time, because it
has no available source code
IIUC, that is
On Thursday, 1 November 2018 at 00:01:04 UTC, Stefan Koch wrote:
On Wednesday, 31 October 2018 at 23:14:08 UTC, Bastiaan Veelo
wrote:
Currently, BitArray is not usable at compile time, so you
cannot do
```
enum e = BitArray([1, 1, 1, 0]);
```
This gives
On Thursday, 1 November 2018 at 00:01:04 UTC, Stefan Koch wrote:
Tell me which version are you using and I'll make it for you.
By the way this is a really generous offer, thanks for being like
that!
On Wednesday, 26 December 2018 at 05:43:47 UTC, Vitaly wrote:
On Tuesday, 25 December 2018 at 17:08:00 UTC, Neia Neutuladh
wrote:
1. Find the Thread object:
Tid threadId = spawn();
auto thread = Thread.getAll.filter!(x => x.id ==
threadId).front;
2. Check the `isRunning` property.
The
On Tuesday, 25 December 2018 at 14:44:43 UTC, Vitaly wrote:
Hi all.
I can not understand how to track me that the thread has
finished work.
eg:
import std.concurrency;
void myThread ()
{
// Do the work
}
void main ()
{
Tid thread = spawn (& myThread);
// It is necessary to check whether the
On Tuesday, 26 March 2019 at 05:29:08 UTC, Michelle Long wrote:
The idea is to be able to make sure one can modify a class and
drop it in for the original and it work in all cases. With
alias this, it can fail unless we can alias it too.
This sounds like mocking, this answer might be of help:
On Monday, 25 March 2019 at 09:27:03 UTC, Victor Porton wrote:
/tmp/temp_7F3C101460D0.d(9,5): Error: template instance
`synchronizedMemoize!f` template `synchronizedMemoize` is not
defined, did you mean sychronizedMemoize(alias fun)()?
Why the error?
Sometimes, template error messages are
On Saturday, 6 April 2019 at 12:06:22 UTC, Robert M. Münch wrote:
The idea is, that I can write a string (or maybe even a scope
block?) in my DSL and use a CTFE grammer to transpile the code.
Are you aware of Pegged[1]? It’s for exactly that.
[1] http://code.dlang.org/packages/pegged
On Saturday, 23 February 2019 at 23:35:14 UTC, solidstate1991
wrote:
On Saturday, 23 February 2019 at 19:21:10 UTC, Bastiaan Veelo
wrote:
It works for me:
https://run.dlang.io/gist/473b0021487275751accaebeb00be05c
-- Bastiaan
Still no luck, not even with memcpy.
There's even more mystery
On Sunday, 24 February 2019 at 13:09:15 UTC, Victor Porton wrote:
Let f be a variadic function:
Result f(...);
How to implement variadic function g which calls f with the
same arguments as one it receives?
Result g(...) {
// ...
}
I don’t know if you can, but if at least g is a variadic
On Sunday, 24 February 2019 at 12:10:22 UTC, Bastiaan Veelo wrote:
1) You get "immutable(Color)(#{overlap raw, colors})" on
immutable Color because the `Color.toString()` method is not
const (corrected in the Gist). This is a bug in
pixelperfectengine. Likewise, getters like `green()` should
On Friday, 22 February 2019 at 11:36:35 UTC, solidstate1991 wrote:
If I want to copy an array of structs with .dup (cannot post
the link in question here at the moment due to non-working
clipboard, it's Color from pixelperfectengine.graphics.common)
I get all zeroes instead of the values from
On Friday, 8 March 2019 at 09:24:25 UTC, Vasyl Teliman wrote:
I've tried to use Mallocator in BetterC but it seems it's not
available there:
https://run.dlang.io/is/pp3HDq
This produces a linker error.
I'm wondering why Mallocator is not available in this mode (it
would be intuitive to
On Monday, 18 March 2019 at 22:25:10 UTC, clothlen wrote:
Howdy;
I'm trying to extend my Python program with D, but I'm having
trouble accessing a D class's
field/attribute/property/something.
My D file looks like this:
```
module simpletest;
import pyd.pyd;
import std.stdio;
class
On Tuesday, 19 March 2019 at 08:50:15 UTC, boolangery wrote:
Hi,
I want to use a constant associative array in a ctfe-able
function.
Example:
string ctfeableFunction()
{
return Foo["foo"];
}
Then I force ctfe with:
enum res = ctfeableFunction();
When I use an enum like:
enum Foo =
On Wednesday, 20 March 2019 at 08:11:27 UTC, boolangery wrote:
Got it ! Thank you, so I need to write:
enum string[string] CtfeFoo = ["foo" : "bar"];
static immutable string[string] Foo;
static this()
{
Foo = CtfeFoo;
}
string ctfeableFunction()
{
if (__ctfe)
return
On Friday, 15 March 2019 at 19:19:41 UTC, H. S. Teoh wrote:
On Fri, Mar 15, 2019 at 06:46:25PM +, bauss via
Digitalmars-d-learn wrote:
On Friday, 15 March 2019 at 18:04:05 UTC, Bastiaan Veelo wrote:
> In the code below (https://run.dlang.io/is/d0oTNi), ifThrown
> is inferred as un@safe. If
On Friday, 15 March 2019 at 18:46:25 UTC, bauss wrote:
On Friday, 15 March 2019 at 18:04:05 UTC, Bastiaan Veelo wrote:
In the code below (https://run.dlang.io/is/d0oTNi), ifThrown
is inferred as un@safe. If instead I write the implementation
of ifThrown out (after res2) then it is @safe. As
On Friday, 15 March 2019 at 19:24:17 UTC, Bastiaan Veelo wrote:
Will do the filing and maybe experiment a bit.
Bastiaan.
https://issues.dlang.org/show_bug.cgi?id=19741
In the code below (https://run.dlang.io/is/d0oTNi), ifThrown is
inferred as un@safe. If instead I write the implementation of
ifThrown out (after res2) then it is @safe. As far as I can see,
there is no real difference. So why doesn't ifThrown work in this
case, and can it be made to work?
On Friday, 15 February 2019 at 16:40:39 UTC, ag0aep6g wrote:
Your fun_to_dlg fails when the function has parameters.
Hah ok. std.functional.toDelegate() does work in its place though.
As far as I see, it would be possible make the conversion would
work by changing how a delegate's context is
Given a function taking a delegate, for example
```
int fun(int delegate() dg) {return dg();}
```
Sometimes we need to call `fun` with a pointer to a nested
function and other times with a pointer to a top level function.
As function pointers do not implicitly convert to delegates, this
does
On Friday, 15 February 2019 at 14:30:45 UTC, Alex wrote:
There is
https://dlang.org/library/std/functional/to_delegate.html
Ah, there it is :-) Thanks.
A templated function also works.
```
int genfun(F)(F dg) {return dg();}
int top_level() {return -1;}
void main()
{
int nested()
On Friday, 15 February 2019 at 17:28:45 UTC, H. S. Teoh wrote:
On Fri, Feb 15, 2019 at 05:40:39PM +0100, ag0aep6g via
Digitalmars-d-learn wrote:
Your fun_to_dlg fails when the function has parameters.
Yes. Delegates are basically syntactic sugar for a function
pointer with an implicit first
On Friday, 17 May 2019 at 18:36:00 UTC, ag0aep6g wrote:
I'd suggest "17 ms, and 553.1µs" for a better default (1 hns is
0.1 µs, right?). No weird "hnsecs", no false precision, still
all the data that is there.
I was going to propose the same. Hns is weird.
Bastiaan.
On Monday, 13 May 2019 at 20:39:57 UTC, Steven Schveighoffer
wrote:
Why? I can't even use it at compile time...
pragma(msg, moddata.length);
Is that a good test or "usable at compile time", though? Isn't
pragma(msg) done at an earlier stage than CTFE? I think that was
the argument for
On Sunday, 12 May 2019 at 13:39:15 UTC, Robert M. Münch wrote:
When developing Windows GUI applications I use:
// detach from console and attach to a new one, works for
x86 and x86_64
FreeConsole();
AllocConsole();
freopen("CONIN$", "r", stdin);
freopen("CONOUT$",
On Saturday, 11 May 2019 at 15:48:44 UTC, Bogdan wrote:
What would be the most straight-forward way of mapping the
members of an enum to the members of another enum (one-to-one
mapping) at compile time?
If I understand your question correctly, you have two enums of
equal length, and you want
On Sunday, 12 May 2019 at 17:53:56 UTC, Bastiaan Veelo wrote:
On Saturday, 11 May 2019 at 15:48:44 UTC, Bogdan wrote:
What would be the most straight-forward way of mapping the
members of an enum to the members of another enum (one-to-one
mapping) at compile time?
If I understand your
1 - 100 of 205 matches
Mail list logo