On Friday, 27 December 2019 at 18:51:31 UTC, Adam D. Ruppe wrote:
On Friday, 27 December 2019 at 18:49:32 UTC, Sjoerd Nijboer
wrote:
Should concatenating the list and mixing that in work too?
yeah that'd work too. As long as all the overloads are coming
from the same source, D allows it.
On Friday, 27 December 2019 at 18:34:49 UTC, Adam D. Ruppe wrote:
On Friday, 27 December 2019 at 18:22:10 UTC, Sjoerd Nijboer
wrote:
When calling the mixin directly instead of through the
template mixin it breaks with thesame error message.
What exactly did you do here?
I meant to say that
I've got a snippet of code which I have narrowed down to the
following:
'import std.stdio;
enum string[] mixins = ["public bool qux(int i, char c)
{
throw new Exception(\"not implemented\");
// Add all arguments to a struct and serialize
that struct.
On Sunday, 11 August 2019 at 16:32:20 UTC, Simen Kjærås wrote:
[...] Something like this:
import std.meta : Filter;
import std.traits : isFunction;
import std.algorithm.searching : canFind;
enum isNonspecialMemberFunction(string name) =
!ctorAndDtor.canFind(name) &&
The following snippet doesn't compile
I am trying to reflect on a class and only do an operation with
all member functions of a class.
But I can't seem to use a filter to only get the member functions
out of a type T.
I understand that there are two errors in my snippet.
1) It cannot mixin a
On Sunday, 14 July 2019 at 19:59:36 UTC, Adam D. Ruppe wrote:
but I think even attempting this is overcomplicating.
static foreach (name; FunctionNames)
{
name ~ " : " ~ name ~ "(); break;";
}
I eventually went with
`switch (mixin(index))
{
static
I am trying to create a template function with a switch case
inside it.
The function signature is:
`static void doSwitch(T...)(int i)`
The code it must generate for `doSwitch!(foo, bar)()` is
`{
switch (int)
{
foo:
foo();
return;
bar:
On Friday, 5 April 2019 at 22:08:50 UTC, Adam D. Ruppe wrote:
Weird combination of cases that maybe should be illegal.
It errors with the highly descriptive errormessage:
app.obj(app)
Error 42: Symbol Undefined __D8mymodule3BarFZ3fooMFZCQx3Foo
Error: linker exited with status 1
module mymodule;
class Foo{}
Foo Bar()
{
Foo foo();
return foo;
}
int main()
{
auto foo = Bar();
return 0;
}
This code doesn't compile with a linker error that there's a
missing symbol for `Foo Bar()` on windows.
After all, `Foo foo();` isn't legitimate
On Friday, 5 April 2019 at 14:52:05 UTC, lithium iodate wrote:
You are just having a little issue with operator precedence
there. Your code attempts to get the member `A` from
`MyClass!MyEnum`, if you add braces around it, it'll work just
fine `MyClass!(MyEnum.A)`.
That's really funny
So the following code doesn't compile for some reason, and I
can't figure out why.
enum MyEnum { A, B, C }
class MyClass(MyEnum myEnum)
{
/*...*/
}
int main()
{
MyClass!MyEnum.A a;
}
The error: Error: template instance `MyClass!(MyEnum)` does not
match template declaration
Is there any overhead on the generated interface? Or overhead the
compiler can't trivially optimise away.
Do you have any recocmendations about mixing coe like, don't use
strings for now or try to minimize switching from D to C# and
vice-versa.
Do you have plans to incorportae this as a
On Wednesday, 5 December 2018 at 23:18:49 UTC, H. S. Teoh wrote:
Maybe if you described to us exactly what you want to do, we
could find a way to do it that doesn't involve language holes
that are not guaranteed to work?
Honestly I don't know.
I was just messing around.
My initial question
On Wednesday, 5 December 2018 at 21:21:12 UTC, Adam D. Ruppe
wrote:
Looks intended. It doesn't really make sense to have a public
import inside a function.
I was trying to find a weird corner of the language and maybe do
something funny with conditional imports.
They don't work in functions,
A small question.
Is it intended behaviour that public imports inside function
calls fail with the message "Error: found public instead of
statement", or is it an underdocumented feature?
void foo()
{
public import bar;
}
On Sunday, 2 December 2018 at 17:59:56 UTC, Paul Backus wrote:
The normal way to do this would be to make bar a template and
have the program that uses it pass these parameters to it as
template arguments.
Why didn't I think of that?
It's just initializing a library, of course!
Thank you for
I would like to do something like
`
dmd --buildversion=fooCollection{"a", "b", "c"} -run app.d
...
void bar()
{
static foreach(i; fooCollection)
{
...
}
}
`
The idea being that bar can be packed in a library and the
program that includes this library can decide what
On Friday, 9 November 2018 at 09:17:27 UTC, Alex wrote:
Is it this what you are looking for?
https://dlang.org/phobos/std_traits.html#Parameters
I've been looking over std.traits all day yesterday, how could
I've missed that?
I'm so glad there are people in this forum that want to help out
On Thursday, 8 November 2018 at 21:16:32 UTC, Sjoerd Nijboer
wrote:
I tried tom make a lazyscoped!T but I'm stuck at creating a
constructor and determining the arguments from the Type.
Unfortunately I can't find a way in D to get a list of arguments
at compile time for a given function. Is
On Thursday, 8 November 2018 at 16:31:26 UTC, Neia Neutuladh
wrote:
I believe what you need to do is pass a factory function into
the constructor. This is a bit awkward.
Yep, but I want a "nice and descriptive syntax" for it.
Anyway, here's some code to make it work. It's kind of ugly.
---
On Thursday, 8 November 2018 at 12:45:57 UTC, Alex wrote:
Hmm... not sure, if I got your idea... Do you think about
something like this?
**snip**
class Bar(TFoo) if(is(TFoo : IFoo))
{
typeof(scoped!TFoo()) _foo;
this()
{
_foo = scoped!TFoo();
I'm trying to invert the dependency from the classes `Bar -> Foo`
to `Foo -> IFoo <- Bar` at compile time.
I do want `Foo's` to be embedded into `Bar`
So silly me tried something like this:
module main;
```import std.stdio;
import std.typecons;
void main()
{
auto bar = new
On Saturday, 13 October 2018 at 18:40:58 UTC, Per Nordlöw wrote:
If a D-program GC-allocates via `new` an array spanning
multiple pages but after processing only keeps a slice to it
that fits inside a single `mmape`d page will GC-collection then
free the other unreferenced pages?
I realize
On Friday, 5 October 2018 at 14:55:04 UTC, Dennis wrote:
On Friday, 5 October 2018 at 10:03:35 UTC, Kagamin wrote:
GC allocations are 16 bytes aligned.
Is that an implementation detail or well-defined behavior?
The GC_Allocator doesn't support alignedAllocate from the
IAllocate interface,
On Friday, 5 October 2018 at 10:03:35 UTC, Kagamin wrote:
GC allocations are 16 bytes aligned.
That's perfect. Thank you!
I've got a `struct Foo{ubyte16 field1, field2 fieldn;}` for
which I would like a heap allocation `Foo* foo = new Foo();` But
the fields itsself must be 16 bytes aligned for SIMD instructions.
Is there a neat way to do this in D?
As far as I can tell the GC_allocator doesn't do aligned
On Sunday, 30 September 2018 at 12:32:08 UTC, kinke wrote:
1) `asm {}` is supported by DMD and LDC, but not by GDC.
Good to know.
Guess I will be targeting DMD and LDC then.
4) For x86_64, there are 2 (completely different) ABIs, Win64
and the System V one. Specs can be found online.
In
On Sunday, 30 September 2018 at 12:07:53 UTC, Basile B. wrote:
On Sunday, 30 September 2018 at 11:53:17 UTC, Basile B. wrote:
Hello, i think this should be here
(https://dlang.org/spec/abi.html) because myself i never
remember them correctly without playing a bit with a
disassembler.
After
I'm kinda puzzled.
I'm having trouble getting started with inline asm in D.
Suppowse I have the following:
void Foo(MyStrunct* first_arg, MyStrunct* second_arg)
{
asm
{
naked;
version(X86)
{
/* Do something with the content of I and J. */
}
On Sunday, 9 September 2018 at 04:59:08 UTC, Josphe Brigmo wrote:
Yes, but the fact is they would not appreciate my work because
they do not appreciate it now.
I can't really argue against that logic.
But then again, I fail to see when such a situation would apply.
I personally use the
On Monday, 27 August 2018 at 21:34:53 UTC, RhyS wrote:
My question becomes, how is it possible that D supposedly only
has a income of 3.2K ( opencollective ).
Well, one could aquire grants from Mozila through MOSS or The
Linux Foundation for development. One could market D as the very
next
On Monday, 27 August 2018 at 01:45:37 UTC, Laeeth Isharc wrote:
I think D is a classic example of Clayton Christensen's
Innovators Dilemma. In the beginning a certain kind of
innovation starts at the fringe. It's inferior alongst some
dimensions compared to the products with high market
On Sunday, 26 August 2018 at 16:25:31 UTC, rikki cattermole wrote:
On 27/08/2018 4:09 AM, lurker wrote:
On Sunday, 26 August 2018 at 14:17:33 UTC, Chris wrote:
lurking around this board for a long time and gave up on d2
along time ago. it is to scripty. i can not convince anybody
at work to
On Sunday, 17 June 2018 at 16:52:59 UTC, Neia Neutuladh wrote:
I agree with you for the whole bunch.
Except this one
allocator.make!Foo(args)
new!allocator Foo(args)
One character difference. Doesn't seem like a big deal.
new is a keyword in D right now which gcallocs an object and
emplaces
On Saturday, 16 June 2018 at 05:48:26 UTC, Nick Sabalausky
(Abscissa) wrote:
But short of that...no sugar is likely to happen anytime soon
that isn't library-based, I'm genuinely sorry to report :(
Most of these just seem like an easy win on the attractiveness of
D.
Big benefits of language
For someone coming from a C# background there is some seemingly
simple syntactic sugar missing from D.
* The null conditional operator `?.`
* Something like a `yield return` statement for coroutines.
T* he `async` & `await` keyword from C# make proactor pattern
async code extremely easy to
On Thursday, 24 May 2018 at 07:06:03 UTC, Bastiaan Veelo wrote:
On Thursday, 24 May 2018 at 06:42:51 UTC, Sjoerd Nijboer wrote:
On Thursday, 24 May 2018 at 01:39:56 UTC, Jonathan M Davis
wrote:
If you don't want an implict cast, then why did you declare
an alias this?
Because I wanted an
On Thursday, 24 May 2018 at 01:39:56 UTC, Jonathan M Davis wrote:
If you don't want an implict cast, then why did you declare an
alias this?
Because I wanted an inconvertible type which was exactly like the
int in the example but didn't want the implicit cast.
That's the whole point of
I would REALLY love a way to implement an implicit cast that
wasn't `alias this` based... for reasons that are NOT to
@disable it :P
Well, explicit casts can be annoying at times when type
conversion wouldn't mean loss of precision, but disabling an
implicit cast on any type that has such
On Thursday, 24 May 2018 at 00:53:00 UTC, Manu wrote:
I would REALLY love a way to implement an implicit cast that
wasn't `alias this` based... for reasons that are NOT to
@disable it :P
Well, explicit casts can be annoying at times when type
conversion wouldn't mean loss of precision, but
While tinkering with some code I eventually found that the
following didn't do as I expected
import std.conv;
import std.stdio;
void main()
{
Foo foo = 5;
writeln(foo);
}
struct Foo{
int i;
alias i this;
@disable T opCast(T)();
this(int j)
{i =j;}
}
If the cast in
On Tuesday, 22 May 2018 at 22:17:05 UTC, IntegratedDimensions
wrote:
On Tuesday, 22 May 2018 at 22:10:52 UTC, Alex wrote:
On Tuesday, 22 May 2018 at 21:45:07 UTC, IntegratedDimensions
wrote:
an idea to lock data by removing the reference:
class A
{
Lockable!Data data;
}
The idea is that
On Tuesday, 22 May 2018 at 14:56:52 UTC, Ethan wrote:
Repeat ad infinitum for each slightly different configuration
you want. I always make the point of programmers being lazy by
definition, and not being able to do something as simple as
declare a type with a single statement is an clear
On Monday, 21 May 2018 at 14:36:32 UTC, Jacob Carlborg wrote:
enum Options options = { foo: true, bar: false, a: 42, b:
"guess what this does" };
SomeObject!options o;
--
/Jacob Carlborg
I like this especially if you mix it with:
enum Options options = { foo: true, bar: false, a: 42, b:
On Monday, 21 May 2018 at 14:30:21 UTC, KingJoffrey wrote:
On Monday, 21 May 2018 at 13:39:12 UTC, Sjoerd Nijboer wrote:
While you might say that a unittest shouldn't acces private
members and only public members, there are plenty of testcases
where one would want to write a unittest to set
On Friday, 18 May 2018 at 15:57:06 UTC, bachmeier wrote:
class A {
private int x;
private(this) int y;
}
Instead of such a syntax if this ever comes to be, we could just
introduce a new keyword into the language.
class A {
private int x;
closed int y; //closed for acces outside
On Thursday, 17 May 2018 at 20:38:13 UTC, Sjoerd Nijboer wrote:
But then how do you put this into a mixin template so I can ...
mixin castingRules(typeof(this) T);
I guess I can refine my question to "How do you let a mixin
template detect the template name it is instantiated with and
On Thursday, 17 May 2018 at 16:27:48 UTC, Paul Backus wrote:
On Thursday, 17 May 2018 at 15:25:37 UTC, Sjoerd Nijboer wrote:
I want to make a template mixin that is able to cast one of
these generic structs to the other explicitly. I have a bunch
of these structs and therefore I thought it
Given the following code
`struct Foo(T)
if(isNumeric!T)
{
T t;
.. other code
}
struct Bar(T)
if(isNumeric!T)
{
T t;
.. other code
}
Foo!float foo_float;
Foo!double foo_double;
Bar!float bar_float;
`
I want to make a template mixin that is able
On Sunday, 6 May 2018 at 09:16:24 UTC, Marco de Wild wrote:
If I have to conclude anything, it is that there, in my opinion
and in the context of my philosophy, should not be a one
language during a study. D definitely has a place in there with
how different language features are set up.
On Friday, 4 May 2018 at 11:37:58 UTC, rikki cattermole wrote:
First we need adoption, then maybe we can start designing a
course to help get them going.
Even with adoption, I think the exposure of D and its
capabilities to teachers is too small for them to notice unless
it is exposed to
So i'm a college student in and what bothers me is that there
seem to kind of assume programming languages don't evolve or
don't get replaced by better ones.
Right now if you go to college you'll most likely get tought c++,
c# or java for any comp sci degree. While these languages are
On Wednesday, 11 April 2018 at 21:29:27 UTC, Alex wrote:
I would say, alias template parameter is your friend.
https://dlang.org/spec/template.html#TemplateAliasParameter
class SortedList(T, alias comparer)
It works, thank you!
But just to be shure, there's no way to have this more strongly
I am trying to do a binary insert into my sorted array.
To sort classes and structs I would like to give a delegate `(t)
=> t.myValue` to sort on that value whitout having to implement
an interface or specifically declare opCmp for every class I want
to have sorted.
After all, I might want one
54 matches
Mail list logo