On Thursday, 17 March 2016 at 14:12:38 UTC, Edwin van Leeuwen
wrote:
On Thursday, 17 March 2016 at 13:53:00 UTC, JR wrote:
Interesting, any idea if it is possible to do assignment
within template.. Either:
printVars!(int abc=5,string def="58")();
or something like
printVars!("abc","def",ghi)
On Saturday, 19 March 2016 at 18:36:10 UTC, ric maicle wrote:
I got an error message with the following code saying:
Error: no property 'length' for type 'int[string]'
Shouldn't the error message say 'length()'?
~~~
import std.stdio;
void main() {
int[string] a;
a["one"] = 1;
a["two"]
On Saturday, 19 March 2016 at 17:41:29 UTC, Lass Safin wrote:
On Saturday, 19 March 2016 at 17:40:27 UTC, Lass Safin wrote:
Why:
enum Base {
A,
B,
}
enum Derived : Base {
C, // Gives error, says it can't implicitly convert
expression to Base.
D = 1, // Same error
E = cast
On Thursday, 17 March 2016 at 11:52:13 UTC, Edwin van Leeuwen
wrote:
On Wednesday, 16 March 2016 at 20:53:42 UTC, JR wrote:
void printVars(Args...)()
if (Args.length > 0)
{
import std.stdio : writefln;
foreach (i, arg; Args) {
writefln("%s\t%s:\t%s", typeof(Args[i]).stringof,
On Wednesday, 16 March 2016 at 20:24:38 UTC, data pulverizer
wrote:
Hi D gurus,
is there a way to obtain parameter names within the function
body? I am particularly interested in variadic functions.
Something like:
void myfun(T...)(T x){
foreach(i, arg; x)
writeln(i, " : ", arg);
On Wednesday, 16 March 2016 at 20:43:09 UTC, jkpl wrote:
I try to anticipate the reason why you want this. [...]
I use something *kinda* sort of similar in my toy project to
print all fields of a struct, for debugging purposes when stuff
goes wrong. Getting the names of the member variables i
On Sunday, 13 March 2016 at 20:13:03 UTC, Basile B. wrote:
On Sunday, 13 March 2016 at 20:10:57 UTC, Basile B. wrote:
[...]
Basile beat me to it. Yes, ref const(Array!T) accessor.
http://dpaste.dzfl.pl/cb2bc5cf9917
On Saturday, 12 March 2016 at 09:56:48 UTC, Uldis wrote:
dump(a); // line 10
a.length = 0;
dump(a);
a ~= [1,2,3];
dump(a);
a.length = 0;
dump(a);
a ~= [4,5,6];
dump(a);
I'll let others more knowledgeable explain why, but ta
On Friday, 4 March 2016 at 14:16:55 UTC, Minas Mina wrote:
On Friday, 4 March 2016 at 13:53:22 UTC, aki wrote:
I think what you can do is extract its contents to an array,
iterate it and modify it as you like, and then insert back to
another associative array. I don't think it's efficient but I
Unsure where else to post this, since it feels like it would
intrude on the more serious discussions in the main D forum.
The new forum design is overall great, but it really doesn't work
well on mobile devices. Coupled with field padding the font is
simply too large. (This holds for the norma
On Saturday, 12 December 2015 at 12:43:36 UTC, SimonN wrote:
DMD v2.069.2-b1 on Linux.
import std.algorithm;
int a = max(5, 6);// works, a == 6
int b = max!(int, int)(5, 6); // works, manual instantiation
int c = 5.max(6); // works, UFCS call
I would lik
On Friday, 4 December 2015 at 14:06:26 UTC, Alex wrote:
[...]
hoping it would be faster. This was not the case. Why?
[...]
Is there anything else to improve performance significantly?
Profile. Profile profile profile. Callgrind. Find bottlenecks
instead of guessing them.
On Wednesday, 4 November 2015 at 16:49:59 UTC, JR wrote:
[...]
And my indentation and brace-balancing there is wrong. Shows how
dependent I've become on syntax highlighting.
import core.time;
import std.concurrency;
bool received = receiveTimeout(1.seconds,
writeln("
On Tuesday, 3 November 2015 at 23:16:59 UTC, bertg wrote:
Running the following code I get 3 different tid's, multiple
"sock in" messages printed, but no receives. I am supposed to
get a "received!" for each "sock in", but I am getting hung up
on "receiving...".
[...]
while (true) {
I was chatting with a friend and showed him how printf("%s")
printed random memory in C, whereas writefln("%s") in D threw an
Exception upon execution. It's probably not a completely fair
comparison but that's a different topic.
I admit to being confused as to why it passed compilation at all
On Sunday, 16 November 2014 at 14:16:55 UTC, Artem Tarasov wrote:
writefln("%(%s-%)", ["a", "b", "c"]) doesn't print the intended
a-b-c but surrounds each string with double quotes -
"a"-"b"-"c", which I find inconsistent with the fact that
writefln("%s", "a string") prints the string without a
On Sunday, 12 October 2014 at 19:46:41 UTC, ketmar via
Digitalmars-d-learn wrote:
Hello.
please, how to call template constructor of a class? it's
completely
escaped my mind. i.e. i have this class:
class A {
this(alias ent) (string name) {
...
}
}
and i want to do:
void
On Wednesday, 3 September 2014 at 05:18:42 UTC, Jason den Dulk
wrote:
[...]
While not really answering your question, I believe the idiomatic
way is to use enum here instead of string/char[].
Conjecture: strings are final but the symbol can be redirected to
point to new arrays, such as resul
Is there a big reason why Appender.put doesn't return &this?
http://dpaste.dzfl.pl/bb840e3e349e
It would allow for convenient chaining. :<
On Thursday, 10 July 2014 at 19:33:15 UTC, simendsjo wrote:
On 07/10/2014 06:05 PM, Alexandre wrote:
I have a string X and I need to insert a char in that string...
auto X = "100";
And I need to inser a ',' in position 3 of this string..., I
try to use
the array.insertInPlace, bu
On Monday, 7 July 2014 at 23:47:26 UTC, Aerolite wrote:
So, if you would be so kind, give me a bullet list of the
aspects of D you believe to be good, awesome, bad, and/or ugly.
If you have the time, some code examples wouldn't go amiss
either! Try not to go in-depth to weird edge cases - remai
On Monday, 7 July 2014 at 21:32:30 UTC, JD wrote:
I'm using a compile time regex to find some tags in an input
string. Is it possible to capture the offset of the matches in
some way? Otherwise I have to "calculate" the offsets myself by
iterating over the results of matchAll.
Thanks,
Jeroen
I
On Tuesday, 8 July 2014 at 07:11:26 UTC, Stephan Schiffels wrote:
Hi,
I am using dmd with version: DMD64 D Compiler
v2.065-devel-db2a73d
My program throws a custom exception with a custom error
message at some point. The stack trace (below) is very
uninformative. Is there a way to output th
On Sunday, 8 June 2014 at 08:44:42 UTC, monarch_dodra wrote: of.
If you want to use a bad algorithm, you could also go for
bogosort:
void main() {
auto data = [2, 7, 4, 3, 5, 1, 0, 9, 8, 6, -1];
while (!isSorted(data))
randomShuffle(data);
data.writeln;
}
I'm partial to Mi
On Thursday, 15 May 2014 at 18:15:46 UTC, Charles Hixson via
Digitalmars-d-learn wrote:
Duration can be specified in nanoseconds, but does it make any
sense
to have a value of 1 nanosecond? 0?
My desire is to check whether a message is in the queue, and
then
either move it local to the threa
On Monday, 12 May 2014 at 09:16:53 UTC, Jonathan M Davis via
Digitalmars-d-learn wrote:
Well, that would be a lot of extraneous files, which would be
very messy IMHO.
It also makes it much harder to share private functionality,
because
everything is scattered across modules - you'd be force to u
Given that...
1. importing a module makes it compile the entirety of it, as
well as whatever it may be importing in turn
2. templates are only compiled if instantiated
3. the new package.d functionality
...is there a reason *not* to make every single
function/struct/class separate submodules
On Tuesday, 6 May 2014 at 09:43:10 UTC, FrankLike wrote:
Hi,everyone,
I find the The writeln() function's args can't be ["一" ,"二"]?
why?
Thank you.
Frank.
The problem is that you have a wide-character comma (,) there.
This works:
void main() {
writeln(["一", "二"]);
}
I'm trying to impose limits upon myself to, well, learn.
Currently I'm exploring ways to avoid allocations -- but my
program is running in three threads with considerable amounts of
message passing between them.
Unless I'm misinterpreting my callgraph,
std.concurrency.MessageBox contains a st
On Sunday, 20 April 2014 at 12:53:11 UTC, steven kladitis wrote:
Note sure if you can edit messages once sent.
$13,456.67
245,678,541
On Sunday, 20 April 2014 at 12:50:52 UTC, steven kladitis wrote:
How do you format numbers to have things like.
Leading $ or , or with or without leading ze
30 matches
Mail list logo