On Thursday, 30 July 2020 at 00:27:49 UTC, user1234 wrote:
On Wednesday, 29 July 2020 at 23:57:21 UTC, Jean-Louis Leroy
wrote:
This works:
[...]
I may be missing the obvious...or it's a compiler bug???
Yes and it's just been fixed, see
https://github.com/dlang/dmd/pull/11431.
So
This works:
module test;
void foo(T)(T a, T b) {}
void foo(T)(char a, T b) {}
template InstantiateTemplateAt(alias Module, string name, int
index, T...) {
alias Template = __traits(getOverloads, test, name,
true)[index];
alias InstantiateTemplateAt = Template!(T);
}
pragma(msg,
On Monday, 15 June 2020 at 16:03:08 UTC, jmh530 wrote:
On Monday, 15 June 2020 at 13:17:11 UTC, Jean-Louis Leroy wrote:
[snip]
Nah, I saw it. Well. My take on it has been ready for months
but I had to wait for my employer's permission to publish it.
They are very open-source friendly, and as
On Sunday, 14 June 2020 at 18:49:01 UTC, jmh530 wrote:
On Sunday, 14 June 2020 at 17:19:05 UTC, Jean-Louis Leroy wrote:
[snip]
In case you missed it, I thought you would find this interesting
https://forum.dlang.org/thread/dytpsnkqnmgzniiwk...@forum.dlang.org
Nah, I saw it. Well. My take on
On Sunday, 14 June 2020 at 16:04:32 UTC, Jean-Louis Leroy wrote:
On Sunday, 14 June 2020 at 09:11:58 UTC, Andre Pany wrote:
On Saturday, 13 June 2020 at 19:27:53 UTC, Jean-Louis Leroy
wrote:
On Monday, 18 November 2019 at 23:06:14 UTC, Per Nordlöw
wrote:
Have anybody written support for DUB
On Sunday, 14 June 2020 at 09:11:58 UTC, Andre Pany wrote:
On Saturday, 13 June 2020 at 19:27:53 UTC, Jean-Louis Leroy
wrote:
On Monday, 18 November 2019 at 23:06:14 UTC, Per Nordlöw wrote:
Have anybody written support for DUB project types in Emacs'
projectile?
See:
On Monday, 18 November 2019 at 23:06:14 UTC, Per Nordlöw wrote:
Have anybody written support for DUB project types in Emacs'
projectile?
See:
https://www.projectile.mx/en/latest/projects/#adding-custom-project-types
Normally it should be as easy as this:
(projectile-register-project-type
On Friday, 1 May 2020 at 21:05:17 UTC, Adam D. Ruppe wrote:
On Friday, 1 May 2020 at 20:28:58 UTC, Jean-Louis Leroy wrote:
Something I have overlooked? Any ideas?
There's an old rule, that I can't find in the spec anymore but
I'm still pretty sure it is there, where taking the address of
a
On Friday, 1 May 2020 at 20:43:05 UTC, Steven Schveighoffer wrote:
On 5/1/20 4:28 PM, Jean-Louis Leroy wrote:
Something I have overlooked? Any ideas?
This trick works. No idea who came up with it:
alias thisFunction = __traits(parent, {});
-Steve
I think I get the idea. Alas it doesn't
Is it possible, inside a function template, to create an alias to
the instantiated function? IOW the equivalent of __FUNCTION__,
but yielding an alias?
The closest I came is:
import std.string;
import std.traits;
void foo(T)(lazy T)
{
mixin(
"alias thisFunction = ",
I can alias a function template:
T f(T)(T x) { return x; }
alias g = f;
int a = g(42);
I can alias a static function:
struct S
{
static int f(int i) { return i; }
}
alias sf = S.f;
int b = sf(42);
I can alias to a static function in a template instance:
On Friday, 17 April 2020 at 18:05:39 UTC, Jean-Louis Leroy wrote:
Interesting example, but all hope is not lost. `a` could
(should?) be passed as an alias in __parameters.
Okay I take this back...
On Friday, 17 April 2020 at 17:48:06 UTC, Adam D. Ruppe wrote:
On Friday, 17 April 2020 at 17:31:32 UTC, Jean-Louis Leroy
wrote:
Well, can't do. I need this purely at compile time, and
cross-module.
And the CTFE engine gets weird with it too dmd will have to
fix this.
But default
On Friday, 17 April 2020 at 16:54:42 UTC, Adam D. Ruppe wrote:
void main() {
import std.stdio;
writeln(ParameterDefaults!f.stringof);
}
and it is fine.
Well, can't do. I need this purely at compile time, and
cross-module. That's for supporting UDAs and default parameter
Alas the presence of parameter UDAs breaks
std.traits.ParameterDefaults:
import std.traits;
struct attr;
void f(@attr int);
pragma(msg, ParameterDefaults!f.stringof);
Error:
dmd -c bug.d
bug.d(4): Error: undefined identifier `attr`, did you mean
variable `ptr`?
Thanks to both of you!
As part of implementing full support for attributes in
openmethods, I am developing a reflection library. That helped a
lot.
is() is a bit weird, but I described it in my "D Cookbook" to
some success...
I am going to order it...even though it is not available on
On Tuesday, 14 April 2020 at 21:44:51 UTC, Adam D. Ruppe wrote:
On Tuesday, 14 April 2020 at 21:35:12 UTC, Jean-Louis Leroy
wrote:
I can see them:
There's some weird tricks to it. Check out my old blog sidebar
about it here:
I can see them:
import std.traits;
struct foo;
struct bar;
void f(@foo int, @foo @bar @("baz") real);
pragma(msg, Parameters!f);
// (@(foo) int, @(tuple(tuple(foo), tuple(bar)),
tuple("baz")) real)
...but I cannot find how to get hold of them:
pragma(msg,
How comes?
immutable struct Foo
{
}
pragma(msg, is(Foo == immutable)); // true
immutable interface Bar
{
}
pragma(msg, is(Bar == immutable)); // false
Here's what I am trying to do:
mixin template MakeFun(string ID, int X)
{
int mixin(ID)() { return X; }
}
mixin MakeFun!("one", 1); // int one() { return 1; }
Alas I get:
makefunc.d(3): Error: no identifier for declarator `int`
makefunc.d(3): Error: found `{` when expecting `;`
On Wednesday, 21 February 2018 at 20:27:29 UTC, Steven
Schveighoffer wrote:
On 2/21/18 1:46 PM, Jean-Louis Leroy wrote:
[...]
I think because one is a function, which is allowed to be
overloaded, the other is a symbol.
But clearly, there are some liberties taken when you are
overloading
I am trying to figure out a crispier syntax for templatized open
methods. I am stumbling on this (see comments):
// dmd -run conflict.d
int foo();
struct Foo {
static int foo(int x) { return x; }
}
alias foo = Foo.foo; // overload with an alias - OK
int bar(T)();
int bar(T)(T x) { return
On Sunday, 24 December 2017 at 22:17:23 UTC, Luís Marques wrote:
On Saturday, 2 September 2017 at 20:03:48 UTC, Jean-Louis Leroy
wrote:
jll@ORAC:~/dev/d/tests/modules$ tree
.
├── foo
│ └── bar.d
└── foo.d
I think that shouldn't be allowed. You have a package foo, but
use a normal module
On Saturday, 2 September 2017 at 21:42:59 UTC, Moritz Maxeiner
wrote:
On Saturday, 2 September 2017 at 21:24:19 UTC, Jean-Louis Leroy
wrote:
[...]
Yes, these now both fail because you cannot have a module `foo`
and a package `foo` at the same time (they share a namespace),
I forgot about
On Saturday, 2 September 2017 at 20:48:22 UTC, Moritz Maxeiner
wrote:
So the compiler wants you to import it by the name it has
inferred for you (The fix being either specifying the module
name in foo/bar.d as `module foo.bar`, or importing it as via
`import bar;` in foo.d).
[1]
So I have:
jll@ORAC:~/dev/d/tests/modules$ tree
.
├── foo
│ └── bar.d
└── foo.d
foo.d contains:
import foo.bar;
bar.d is empty.
Now I try compiling:
jll@ORAC:~/dev/d/tests/modules$ dmd -c foo.d
jll@ORAC:~/dev/d/tests/modules$ dmd -c foo/bar.d
So far so good. Now I try it the way dub does
Hi,
I am quite happy with dub, the little package manager that could
:)
Now two questions or suggestions.
I have a package hierarchy (here
https://github.com/jll63/openmethods.d/blob/master/dub.sdl) and I
would like to 'dub run' or 'dub test' everything. Is there a
recursive mode that
On Tuesday, 18 July 2017 at 20:12:13 UTC, Jean-Louis Leroy wrote:
On Tuesday, 18 July 2017 at 20:00:48 UTC, Guillaume Piolat
wrote:
On Tuesday, 18 July 2017 at 19:49:35 UTC, Jean-Louis Leroy
wrote:
Hi,
I want to add a few flags while building with dub. I tried:
On Tuesday, 18 July 2017 at 20:00:48 UTC, Guillaume Piolat wrote:
On Tuesday, 18 July 2017 at 19:49:35 UTC, Jean-Louis Leroy
wrote:
Hi,
I want to add a few flags while building with dub. I tried:
DFLAGS='-d-version=explain' dub test ...
...but DFLAGS does not seem to be honored. In fact
Hi,
I want to add a few flags while building with dub. I tried:
DFLAGS='-d-version=explain' dub test ...
...but DFLAGS does not seem to be honored. In fact I wouldn't
mind adding a builtType to my dub.sdl (but then will it be
inherited by the subpackages) but I don't see how to specify
On Saturday, 15 July 2017 at 08:55:41 UTC, Mike Parker wrote:
On Saturday, 15 July 2017 at 08:29:52 UTC, Jean-Louis Leroy
wrote:
My module has a name in dub.sdl.
No, it does not. That's the name of the DUB project. The module
in this case is source/methods.d. I've never used ddox, but
I began to write documentation for my open method library. After
googling around quite a bit, I came across the incantation:
dub build -b ddox
Problem is, it generates no doc. And I believe that it actually
says so:
Performing "ddox" build using dmd for x86_64.
methods ~genesis: building
I want to create a string while making sure it qualifies as an
identifier. Like this:
struct quote
{
static @property string opDispatch(string str)() { return str; }
}
unittest
{
assert(quote.foo == "foo");
}
Does it already exist somewhere in the language or the library?
J-L
On Tuesday, 11 July 2017 at 21:23:28 UTC, Ali Çehreli wrote:
Default template and function arguments are resolved at
instantiation site, which means __MODULE__ would resolve
automatically to the caller's module. For example, if you have
this module:
__MODULE__ is a string so I cannot pass it
On Tuesday, 11 July 2017 at 17:20:33 UTC, Ali Çehreli wrote:
@Virtual("t", "d", "w")
string fight(Character t, Dragon d, Hands w) {
return "you just killed a dragon with your bare hands.
Incredible isn't it?";
[...]
mixin ProcessMethods();
Great suggestion! I think this could work:
On Tuesday, 11 July 2017 at 17:20:33 UTC, Ali Çehreli wrote:
That's some serious code you've written there and you must be
happy that 'virtual' is not a keyword in D. ;)
Thanks. Haha I would have used virtual_ like I did in C++ ;-)
Maybe others can come up with ideas on a better syntax.
On Monday, 10 July 2017 at 19:11:37 UTC, Ali Çehreli wrote:
On 07/10/2017 11:46 AM, Jean-Louis Leroy wrote:
> Is there something special about ClassInfo that confuses?
Look at this
> example:
>
> struct Foo
> {
>
> }
>
> class Bar
> {
> }
>
> void main()
> {
> Foo*[Bar] a;
> auto aa = a.dup;
Is there something special about ClassInfo that confuses? Look at
this example:
struct Foo
{
}
class Bar
{
}
void main()
{
Foo*[Bar] a;
auto aa = a.dup; // OK
Foo*[ClassInfo] b; // Error: static assert "cannot call
Foo*[TypeInfo_Class].dup because Foo* is not copyable"
auto bb =
When I look at ldc2's object.d I have the impression it's thread
local. I may be wrong though, just beginning to learn about
'shared'.
On Wednesday, 5 July 2017 at 01:43:46 UTC, Ali Çehreli wrote:
On 07/04/2017 05:52 PM, Jean-Louis Leroy wrote:
On Wednesday, 5 July 2017 at 00:28:01 UTC, Ali Çehreli wrote:
On 07/04/2017 04:57 PM, Jean-Louis Leroy wrote:
[...]
No time to dig deeper but this is because the two ranges that
On Wednesday, 5 July 2017 at 00:28:01 UTC, Ali Çehreli wrote:
On 07/04/2017 04:57 PM, Jean-Louis Leroy wrote:
[...]
No time to dig deeper but this is because the two ranges that
chain() receives do not have a common type. (Rather, that type
is 'void'):
[...]
I suspect that that is the
On Tuesday, 4 July 2017 at 23:26:28 UTC, H. S. Teoh wrote:
On Tue, Jul 04, 2017 at 11:27:25PM +, Jean-Louis Leroy via
Digitalmars-d-learn wrote:
I want to create a range that consists of the result of a map()
followed by a value, e.g.:
int[] x = [ 1, 2, 3];
auto y = map!(x => x * x
I want to create a range that consists of the result of a map()
followed by a value, e.g.:
int[] x = [ 1, 2, 3];
auto y = map!(x => x * x)(x);
auto z = y ~ 99; // how???
I have tried several variations: convert 99 to a dynamic array,
to a range, convert range to dynamic array (couldn't
On Monday, 3 July 2017 at 22:34:51 UTC, FoxyBrown wrote:
On Monday, 3 July 2017 at 20:45:19 UTC, bauss wrote:
On Monday, 3 July 2017 at 13:54:42 UTC, Jean-Louis Leroy wrote:
I know how to find all the classes:
foreach (mod; ModuleInfo) {
foreach (c; mod.localClasses) {
//
I know how to find all the classes:
foreach (mod; ModuleInfo) {
foreach (c; mod.localClasses) {
// use c.base to construct inheritance graph
}
}
Can I do the same with all the interfaces? Looking at object.d
gives no clue...
Another meta-programming question ;-)
Inside a variadic function template that takes a list of
arguments, I want to call another function and pass it the
arguments run through another function. In C++ it would look like
this:
template
T double_int(T val) { return val; }
int double_int(int
On Monday, 19 June 2017 at 20:59:33 UTC, Ali Çehreli wrote:
On 06/19/2017 12:54 PM, Jean-Louis Leroy wrote:
I need to process two sequences in parallel (select some
elements of
sequence A depending of the corresponding element of sequence
B). How
can I pass two sequences to a meta-function? I
I need to process two sequences in parallel (select some elements
of sequence A depending of the corresponding element of sequence
B). How can I pass two sequences to a meta-function? I tried
nesting AliasSeqs but I get Perl4 style flattening:
AliasSeq!(AliasSeq!(int, float),
48 matches
Mail list logo