On Wednesday, 31 July 2019 at 18:38:02 UTC, Alexandre wrote:
Should I go for C and then when I become a better programmer
change to D?
Should I start with D right now?
In my oppinion C should have been deprecated about 50 years ago
and it's not worth while to learn it if you are not intereste
On Wednesday, 31 July 2019 at 18:38:02 UTC, Alexandre wrote:
Should I go for C and then when I become a better programmer
change to D?
Should I start with D right now?
In my oppinion C should have been deprecated about 50 years ago
and it's not worth while to learn it if you are not intereste
On Thursday, 1 August 2019 at 21:26:10 UTC, Matt wrote:
Anyone have any other thoughts?
I tried to simplify your example a little bit:
import std.stdio;
import std.range;
import std.algorithm;
auto myFilter(R1, R2)(R1 a, R2 b)
{
return a.filter!(c => c==b.front);
}
struct A
{
int[] s
On Friday, 2 August 2019 at 14:05:20 UTC, SashaGreat wrote:
On Friday, 2 August 2019 at 12:28:45 UTC, berni wrote:
On Wednesday, 31 July 2019 at 18:38:02 UTC, Alexandre wrote:
Should I go for C and then when I become a better programmer
change to D?
Should I start with D right now?
In my opp
I've got a function which takes two strings and should return
them as a ubyte[] with additional zero bytes in between and
around. This works:
ubyte[] convert_string_pair(string first, string second)
{
auto b = new ubyte[](0);
b ~= 0x00 ~ first ~ 0x00 ~ second ~ 0x00;
I've got two associative arrays and want to get a new one, which
is created out of both of them:
This works:
string[int] a = [1:"one", 7:"seven"];
string[int] b = [5:"five", 9:"nine"];
string[int] tmp = a.dup;
foreach (k,v;b) tmp[k] = v;
assert(tmp==[1:"one", 7:"seven", 5:"five", 9:"nine"]);
On Saturday, 24 August 2019 at 19:55:48 UTC, a11e99z wrote:
auto ab = a.byPair.chain( b.byPair).assocArray ?
Not sure, if it is simpler, but a least without tmp. :) Thanks.
Out of curiosity: Browsing the source of stdio.d I found that
flush() is implemented by calling fflush from some C++ library.
What I don't understand: Why is the call to fflush preceded by a
dot?
On Monday, 26 August 2019 at 09:14:23 UTC, Jonathan M Davis wrote:
The dot makes it so that it's specifically referencing a
module-level symbol (be it in that module or an imported
module) instead of a local or member symbol.
Ah, thanks. Now it makes sense! :)
import std.stdio;
void main()
{
real[int] a;
a[0] += 100;
writeln(a);
}
results (independed of the used compiler) in
[0:100]
I was a little bit surprised, because a[0] += 100 should be the
same as a[0] = a[0]+100, which leads to a range violation error.
Furthermore, as we work
On Tuesday, 27 August 2019 at 16:45:53 UTC, Samir wrote:
I never understood why the intial value of floats, doubles and
reals was NaN.
That's for detecting uninitialised variables. If the result of a
calculation is NaN, it's likely, that you forgot to initialise
the variable.
On Tuesday, 27 August 2019 at 16:25:00 UTC, Samir wrote:
As I've mentioned on the list before, I really struggle to
understand how some of the std.algorithm functions such as
`map` work when combined with things like `array`, `sort` and
especially `zip` but really appreciate the support I find
Iterating of some structure and removing elements thereby is
always errorprone and should be avoided. But: In case of AA, I've
got the feeling, that it might be safe:
foreach (k,v;ways)
if (v.empty)
ways.remove(k);
Do you agree? Or is there a better way to achieve this?
On Friday, 30 August 2019 at 15:00:59 UTC, Paul Backus wrote:
Whether you actually get an error at runtime depends on the
load factor of the AA. If it drops below a certain threshold,
the AA will be resized [1], and its original memory will be
freed [2].
It could still work, depending on how
I've tried to make a small example, but it's not easy to get this
reduced further. At least I didn't manage. The following program
can also be found at https://run.dlang.io/is/p6l7xN
void main()
{
auto foo = Ways([Way([8,2,3,0]),Way([4,6,2]),Way([4,7,2,6])]);
foo.remove_odds();
as
On Monday, 2 September 2019 at 14:20:11 UTC, Paul Backus wrote:
If you have an existing delegate that you want to use with
opApply, the easiest way is like this:
void delegate(Thing) myDelegate = ...;
foreach(thing; things) {
myDelegate(thing);
}
// Equivalent to: things.opApply((Thing t)
On Tuesday, 3 September 2019 at 20:06:27 UTC, Ferhat Kurtulmuş
wrote:
I know, it is foreach loop in question. How about using a
reverse for loop like:
for (size_t i = arr.length ; i-- > 0 ; ){
arr.remove(i);
}
This would be good, if it where for slices. But with associative
arrays, this
I still struggle with the concept of immutable and const:
import std.stdio;
void main()
{
auto p = Point(3);
auto q = p.x;
writeln(typeof(q).stringof);
}
struct Point
{
@property immutable long x;
}
The type of q is immutable(long). But I need a mutable q. I found
two ways:
On Thursday, 5 September 2019 at 08:16:08 UTC, Daniel Kozak wrote:
in this case you can just use:
auto q = cast()p.x;
Ahh, great! :-)
But that directly gets me to the next question:
import std.stdio;
void main()
{
Point[] q = [Point(1),Point(3),Point(2)];
import std.algorithm.sear
On Thursday, 5 September 2019 at 08:44:35 UTC, berni wrote:
This doesn't compile:
[...]
Any idea, how to get around this?
Found the answer myself: q.map!(a=>a.x).minElement; :-)
On Thursday, 5 September 2019 at 08:56:42 UTC, berni wrote:
[..]
And one more question:
import std.algorithm: reverse;
writeln(q.reverse);
Here the compiler complains with:
test.d(8): Error: template std.algorithm.mutation.reverse
cannot deduce function from argument types !()(Point[]),
On Thursday, 5 September 2019 at 10:47:56 UTC, Simen Kjærås wrote:
https://dlang.org/library/std/range/retro.html
Yeah, that worked. Thanks. :-)
Don't worry about asking questions
OK. Then here's the next one:
Point[long] q;
q[1] = Point(3);
Leads to:
test.d(7): Error: cannot modify s
On Thursday, 5 September 2019 at 11:22:15 UTC, drug wrote:
05.09.2019 14:17, berni пишет:
Point[long] q;
q[1] = Point(3);
Leads to:
test.d(7): Error: cannot modify struct q[1L] Point with
immutable members
But why do you try to modify immutable data? What is your
point? Could you descri
On Thursday, 5 September 2019 at 12:15:51 UTC, drug wrote:
One solution could be using either pointer to `const(Point)` or
class here (to avoid pointer using)
https://run.dlang.io/is/rfKKAJ
OK. This are two solutions and although I'll probably not going
to use any of those (due to other reaso
On Thursday, 5 September 2019 at 13:27:55 UTC, drug wrote:
[...]when you put it into an AA you modify old value
Why?!? :-o When putting it into an AA it will be copied to a
different place in memory, but the value is still the same, it's
not modified. Sorry, but I still think, there is someth
On Thursday, 5 September 2019 at 15:48:40 UTC, Ali Çehreli wrote:
That's the misunderstanding: The existing object is assigned
over. The address is the same:
void main() {
int[int] aa;
aa[1] = 1;
const oldPointer = (1 in aa);
aa[1] = 11;
assert(oldPointer is (1 in aa)); // Passes
}
On Thursday, 5 September 2019 at 20:10:03 UTC, ag0aep6g wrote:
You're not putting an immutable int into an AA. You're copying
the value of an immutable int to a mutable one.
but I can't do that with a struct, having an immutable member.
When I remove that immutable inside of the struct it work
On Thursday, 5 September 2019 at 21:22:12 UTC, Ali Çehreli wrote:
If it makes for the type to have immutable (or const) members,
then fine; with the understanding that objects of that type
cannot be assigned or mutated any other way, we can define them
like that. What I meant is, because we wan
On Friday, 6 September 2019 at 08:47:07 UTC, Kagamin wrote:
Physical objects work like reference types. A place on
bookshelf is at one coordinate and a book is at another
coordinate, you don't copy the book, you fill a place on
bookshelf with a reference to the book.
So it's more like a piece
On Sunday, 8 September 2019 at 10:04:57 UTC, Joel wrote:
I'm trying to understand delegates. Is there any good ways I
can get a better understanding of them?
I wrote a foreach loop using opApply. A side effect of that was,
that after I managed to do this I understood delegates. :-)
I'd like to write a template, that takes a different default
value depending on the type of a variable. I tried this, but it
doesn't work:
void main()
{
double a = 1e-8;
double b = 1e-10;
float c = 1e-4;
float d = 1e-6;
assert(!test(a));
assert(test(b));
assert(!test(c));
On Wednesday, 11 September 2019 at 09:05:47 UTC, Ali Çehreli
wrote:
Like this?
Yet an other template! That's great! :-)
I'm not sure, if this is the right place to ask, but I couldn't
find a better one either.
I'm trying to install D on my old 32-bit machine (debian stable).
First I tried to install a precompiled version and now I followed
[1]. In both cases, I always get a segmentation fault when I try
to run
On Tuesday, 17 September 2019 at 18:13:06 UTC, Adam D. Ruppe
wrote:
Did you make sure the old version was totally uninstalled
before the new version was attempted to be built? This thing
often happens because of a compiler/runtime version mismatch,
typically because the old version didn't get f
Is it possible to simplfy this?
static if (is (T==Complex!double) || is (T==Complex!float) || is
(T==Complex!real))
On Wednesday, 18 September 2019 at 11:25:21 UTC, Norm wrote:
I usually do something like the following:
Ah great. I was looking for "is(T == Complex!R, R)". :-) Thanks!
The following code doesn't compile:
import std.stdio;
void main()
{
import std.complex: abs, complex;
import std.math: abs;
auto a = complex(1.0,1.0);
auto b = 1.0;
writeln(abs(a));
writeln(abs(b));
}
The error message depends on the order of the two import
statements. Se
On Wednesday, 18 September 2019 at 12:37:28 UTC, Simen Kjærås
wrote:
How to resolve this, though? The simplest solution is to not
use selective imports:
import std.math;
import std.complex;
writeln(abs(complex(1.0,1.0)));
writeln(abs(1.0));
That works. But: I'm trying to writ
On Wednesday, 18 September 2019 at 13:57:53 UTC, ag0aep6g wrote:
You're probably hitting this issue:
https://issues.dlang.org/show_bug.cgi?id=19116
Yes, sounds similar. I tried PR 9981, but that didn't work on my
machine. Similar message, just an other file, that cannot be
compiled (dmd/backe
On Thursday, 19 September 2019 at 07:26:17 UTC, Simen Kjærås
wrote:
That does indeed fail to compile, and there's no easy way to
introduce the module-level abs() function to the scope. Again
though, MergeOverloads to the rescue:
I'm not sure, if MergeOverloads will be accepted into std/math.d.
On Thursday, 19 September 2019 at 11:16:12 UTC, Simen Kjærås
wrote:
Might I ask what specifically you're working on?
Of course. It's about issue 15881 (and 15763), namely approxEqual
not always doing, what people think it should do. (As a side
note: I stumbled over this, when I wanted to file
I've got the folling function which returns a RegexMatch!string:
auto extract_list(const string entry)
{
// check if entry is valid
return matchAll(entry, some_regex);
}
I call this function using enforce(extract_list(some_argument)).
I think, that enforce is quite useless in this ve
a) I've got an int[] which contains only 0 und 1. And I want to
end with a string, containing 0 and 1. So [1,1,0,1,0,1] should
become "110101". Of course I can do this with a loop and ~. But I
think it should be doable with functional style, which is
something I would like to understand better.
On Saturday, 15 September 2018 at 03:25:38 UTC, Paul Backus wrote:
On Friday, 14 September 2018 at 20:43:45 UTC, SrMordred wrote:
What you want is std.range.chunks
auto a = [1,0,1,1,1,0,1,0,1,1,1,1,0];
a.map!(to!string)
.join("")
.chunks(4)
.map!(to!string) //don´t know why
Anotherone I'm not getting to work: From some output with
newlines I want to discard all lines, that start with a # and
select part of the other lines with a regex. (I know the regex
r".*" is quite useless, but it will be replaced by something more
usefull.)
I tried the following, but non wor
Can you post a complete, runnable example that illustrates your
problem?
Strange as it is, now it works here too... - I don't know, what
went wrong yesterday. Thanks anyway. :-)
The following program does not compile:
import std.stdio;
import std.algorithm;
struct A
{
struct S
{
int x;
}
const bool foo(in S s, in int k)
{
return s.xa.foo(3)).writeln;
}
}
void main()
{
A().bar();
}
I get (using rdmd):
test.d(18): Error: no proper
The problem is more general: you can only use top-level symbols
in UFCS.
You can use an identity alias template to bypass this:
https://blog.thecybershadow.net/2015/04/28/the-amazing-template-that-does-nothing/
(search for UFCS in the page).
Good to know. :-)
I need to execute a program and capture stdout, which I hoped
std.process.execute would do. But unfortunatly this command also
captures stderr, which I need to be ignored. When looking at the
implementation of std.process.execute I see, that I can probably
do this by removing "Redirect.stderrTo
On Thursday, 20 September 2018 at 07:36:06 UTC, Paul Backus wrote:
Looks like `Config.stderrPassThrough` [1] should do what you
want:
const result = execute(args[1..$], null,
Config.stdErrPassThrough);
[1]
https://dlang.org/phobos/std_process.html#.Config.stderrPassThrough
In theory t
On Thursday, 20 September 2018 at 14:10:44 UTC, Steven
Schveighoffer wrote:
Hm... 2.079.0 had it:
Sorry, I made a mistake while testing and after I found out, that
it was not available in the documentation at dpldocs.info I
concluded, that it must be a really new feature. But now it seems
to
I expect this small program to throw an Exception:
import std.stdio;
import std.range;
void main()
{
auto a = [[1,2],
[4,5,3]];
a.transposed!(TransverseOptions.enforceNotJagged).writeln;
}
But it just outputs:
[[1, 4], [2, 5], [3]]
Is it a bug or is it me who's doin
On Saturday, 22 September 2018 at 12:52:45 UTC, Steven
Schveighoffer wrote:
It was suggested when transposed was fixed to include opIndex,
but never implemented.
Maybe I'm too naive, but isn't it easy to implement it just the
same way, it is done with transverse? That is: putting the
"static
I've got the following code, which works, but obviously contains
duplication. Is there a way to move that
"dissection_available?...:..." to the place, where it should be?
return dissection_available
?solution.dup
.transposed.map!(a=>a.map!(b=>"?#."[b]).array)
.zi
I've got a lot of code with two-dimensional arrays, where I use
stuff like:
assert(matrix.all!(a=>a.all!(b=>b>=0)));
Does anyone know if there is a 2D-version of all so I can write
something like:
assert(matrix.all2D!(a=>a>=0));
Is there a way to check if a function is indeed executed at
compile time or not? (Other than going through the whole
executable binaries...)
I tried
static this()
{
if (__ctfe) pragma(msg,"works");
// some other stuff
}
but unfortunatley this "if" is also executed at compile time,
when
On Tuesday, 18 December 2018 at 13:53:01 UTC, Stefan Koch wrote:
Why would you need to know?
Well, first out of curiosity. But there are also other reasons:
I've got a large immutable array. Without CTFE I'd use some php
script and add it as a large literal. With CTFE I don't need that
php s
On Tuesday, 18 December 2018 at 14:32:29 UTC, Adam D. Ruppe wrote:
CTFE is used if and only if it MUST be used by context. That's
a runtime function, so no ctfe.
Do something like:
int[4] generate() {
int[4] tmp;
foreach(i; 0..4) tmp[i] = i;
return tmp;
}
static immutable int[4] clu
I'd like to process a (binary) file as a buffered InputRange but
I havn't found anything yet. Is there anything or do I have to
write it on my own?
On Friday, 5 July 2019 at 17:57:39 UTC, Les De Ridder wrote:
File.byChunk[1] should do the trick.
[1] https://dlang.org/library/std/stdio/file.by_chunk.html
Not sure, if this is, what I'm looking for. I'd like to do
something like
buffered_file.map!(a=>2*a).writeln();
When I understand i
On Friday, 5 July 2019 at 18:45:01 UTC, Les De Ridder wrote:
On Friday, 5 July 2019 at 18:29:36 UTC, berni wrote:
On Friday, 5 July 2019 at 17:57:39 UTC, Les De Ridder wrote:
File.byChunk[1] should do the trick.
[1] https://dlang.org/library/std/stdio/file.by_chunk.html
Not sure, if this is,
I want to copy the first n items of a range to an array, removing
these items from the range.
This works:
foreach (i;0..n)
{
data ~= r.front;
r.popFront();
}
but looks a little bit arkward.
I came up with this now:
data = r.take(n).array;
This works partly, because the values of r
struct A
{
void c() {}
struct B
{
void d()
{
c();
}
}
}
When compiling this with rdmd I get the message: "Error: this for
c needs to be type A not type B". Is there a way to call c from d?
On Thursday, 4 July 2019 at 17:00:33 UTC, Q. Schroll wrote:
The prime example is printing the comma when printing a list:
There is one between any two elements, but neither is one at
front or behind the last one.
If it is just for printing commas in between, you can use
range.join(", ")
htt
On Saturday, 6 July 2019 at 11:48:51 UTC, a11e99z wrote:
sure
auto take_consuming( R )( ref R r, int cnt ) {
auto tmp = r.take( cnt ).array;
r = r.drop( cnt );
return tmp;
}
don't thank
Doesn't look like what I'm looking for, as it is exactly the same
I allready found.
Maybe I ne
Now I found this:
https://forum.dlang.org/thread/eobdqkkczquxoepst...@forum.dlang.org
Seems to be intentional, that this doesn't work. In my case I'm
able to move d() into the outer struct...
Now it's getting weird. Meanwhile I encountered, that take()
sometimes consumes and sometimes not. Where can I learn, what is
the reason behind this behavior? And how can I handle this?
A small example showing this strange behaviour:
import std.stdio;
import std.algorithm.iteration;
import std.range;
enum BUFFER_SIZE = 1024;
void main(string[] args)
{
auto a = (new File(args[1]))
.byChunk(BUFFER_SIZE)
.joiner;
writeln(a.take(5));
writeln(a);
}
Using
On Saturday, 6 July 2019 at 14:48:04 UTC, Adam D. Ruppe wrote:
[...]
So this is a case of input range behavior - always consuming
the underlying file - combined with buffering of two elements
at once, leaving 5,6 behind, and the reuse of the buffer
meaning you see that 5,6 again on the next ca
I start to understand: A (lazy) range is something like a
voucher: byChunk() does not provide the data immediately, but
only a voucher to hand you a chunk (an array of 2 bytes in my
example above) a time. This voucher is passed to joiner(), which
keeps that voucher and hands me out a new vouche
On Sunday, 7 July 2019 at 09:01:53 UTC, Jonathan M Davis wrote:
Without slicing, that's impossible without iterating over the
elements multiple times.
That's what I thought too, but meanwhile I think it is possible.
To get it working, the second range needs to know about the first
one and whe
On Sunday, 7 July 2019 at 21:55:17 UTC, Jonathan M Davis wrote:
Having one range know about the other isn't enough. That just
means that the take range would tell the other range that it
had popped an element off, and then the other would know that
it had to pop an element off. That still invol
Hurray, it works! :-)
https://run.dlang.io/is/2GMq34
I have to use classes to avoid copying when arguments are passed
to a function. (And yes, there should of course be much more
checks, especially when there are to few elements in the original
range. And it could be speed improved and so on.
Part of my code looks like this:
out (result)
{
if (result==true)
{
lots of assertions...
}
}
I would prefer an early exit like:
out (result)
{
if (result==false) return;
lots of assertions...
}
Is this possible somehow (return and break don't do the job...).
The only thing
On Thursday, 22 March 2018 at 16:22:04 UTC, Ali Çehreli wrote:
Never thought of it before. :) I would put all that code into a
function and call from the out block.
I rejected this, because I've got an unease feeling using extra
functions in contract programming. Can't tell, where this feeling
With X not known at compile time:
auto arr = new int[][](X,X);
for (int i=0;i
Is there anything better for this? I mean, the program will fill
the array with zeroes, just to overwrite all of them with -1.
That's wasted execution time and doesn't feel D-ish to me.
On Sunday, 5 February 2017 at 21:14:33 UTC, Daniel Kozak wrote:
http://stackoverflow.com/questions/24600796/d-set-default-value-for-a-struct-member-which-is-a-multidimensional-static-arr/24754361#24754361
Dne 5.2.2017 v 21:33 berni via Digitalmars-d-learn napsal(a):
With X not known at
auto arr = uninitializedArray!(int[][])(ROWS,COLS);
arr.each!"a[]=-1";
This looks like what I was looking for. At least I think I
understand what's going on here. The other two suggestions are
beyond my scope yet, but I'll come back, when I improved on my D
skills. Thanks for your replies.
I've got two source files in two directories:
Common/common.d
module common;
import std.stdio;
int main(string[] args)
{
Foo foo = cast(Foo)Object.factory("special.Bar");
foo.do_something();
return 0;
}
abstract class Foo {
abstract void do_something();
}
Special/special.d
dmd only compiles in the files you actually pass to it. rdmd
will try to find the required files automatically.
Since you didn't pass the file with the function to dmd, it
knows it exists, but leaves it out of the final link (it
assumes it might come from a library or something). That's why
y
On Thursday, 9 February 2017 at 19:10:55 UTC, Daniel Kozak wrote:
Dne 9.2.2017 v 17:20 berni via Digitalmars-d-learn napsal(a):
[...]
Ah ok, I understand. So calling with "dmd Special/special.d
Common/common.d" works.
But when I compile common.d to common.o (with dmd -c comm
$> dmd Special/special.d Common/common.o Special/special.d(4):
Error: module common is in file 'common.d' which cannot be read
import path[0] = /usr/include/dmd/phobos
import path[1] = /usr/include/dmd/druntime/import
This is not a linker error. It's a compiler error. You need
common.d for the
On Tuesday, 7 February 2017 at 19:06:22 UTC, berni wrote:
auto arr = uninitializedArray!(int[][])(ROWS,COLS);
arr.each!"a[]=-1";
This looks like what I was looking for. At least I think I
understand what's going on here. The other two suggestions are
beyond my scope yet, but I'll come back, w
On Friday, 10 February 2017 at 09:25:04 UTC, Daniel Kozak wrote:
Now I tried this with a named instead of a magic constant e.g.
immutable VALUE=-1;
arr.each!"a[]=VALUE";
And it doesn't work anymore. I've no clue, why... Can you help
me?
Because it does not see VALUE, you need to use delegate
On Friday, 10 February 2017 at 09:34:39 UTC, berni wrote:
On Friday, 10 February 2017 at 09:25:04 UTC, Daniel Kozak wrote:
Now I tried this with a named instead of a magic constant e.g.
immutable VALUE=-1;
arr.each!"a[]=VALUE";
And it doesn't work anymore. I've no clue, why... Can you
help
I need to measure time elapsed in seconds, like this:
auto start = Clock.currStdTime();
// some stuff
auto stop = Clock.currStdTime();
auto duration = (stop-start)/1000;
This works, but I wonder if there is something better that using
the magic constant 1000. I read about 10.secs givi
I'm not sure if this is considered a bug:
import std.stdio;
import std.string;
int c = 0;
void main()
{
try {
write(++c," ");
stdout.flush();
int[10] tmp;
throw new Exception(format("%s",tmp));
} finally
{
main();
}
}
Output:
1 2 3 4 5 6 7
On Wednesday, 15 February 2017 at 16:11:36 UTC, drug wrote:
No, you recursively call main() and get segfault (due to stack
overflow) as expected
I thought, that an stack overflow leeds to an exception. But
that's not true, as I now see. Thanks for your answer.
On Wednesday, 15 February 2017 at 15:58:41 UTC, Jonathan M Davis
wrote:
[...]
MonoTime before = MonoTime.currTime;
Thread.sleep(dur!"msecs"(1000));
MonoTime after = MonoTime.currTime;
Duration timeElapsed = after - before;
writeln(timeElapsed);
}
```
I get: "1 sec, 26 μs
The following code doesn't work:
int no = fileno(stderr);
The error message is:
test.d(7): Error: function core.stdc.stdio.fileno
(shared(_IO_FILE)*) is not callable using argument types (File)
How can I cast stderr to something, that fileno() accepts?
Something similar happend now, but this time it works with dmd
and rdmd produces the error:
The command that works is
dmd a.d b.o
where b.o is a precompiled c file, similar to
https://github.com/dlang/druntime/blob/master/src/core/stdc/errno.c
When using rdmd it doesn't work anymore. When I
On Friday, 17 February 2017 at 16:08:11 UTC, Adam D. Ruppe wrote:
Try
fileno(core.stdc.stdio.stderr);
to force it to use the C stderr object instead of the D one.
Alternatively, fileno(stderr.getFP()) should do it too.
http://dpldocs.info/experimental-docs/std.stdio.File.getFP.html
Many than
On Friday, 17 February 2017 at 19:16:44 UTC, Adam D. Ruppe wrote:
Yes, that is my documentation fork, it has a search feature if
you do dpldocs.info/some_term and it tries to be easier to read
and navigate, let me know how you like it!
What I've seen so far, looks quite good.
What I didn't un
I wonder if it's possible to do something like this:
import std.stdio;
void main(string[] args)
{
if (args[1]=="a")
{
write("A");
scope (exit) write("B");
}
write("C");
}
I expected the output to be ACB not ABC. I understand, that the
scope ends at the end of the i
Just a note - I found something, that works:
import std.stdio;
void main(string[] args)
{
immutable cond = args[1]=="a";
if (cond) write("A");
scope (exit) if (cond) write("B");
write("C");
}
I'm using the immutable variable to avoid, that the condition
changes later.
I'm new here too (never heard of D before 2017).
c). The whole community seems infused with both the Feminism/SJW
I didn't tried out Rust, but that would draw me away too.
(Incidentally it was a comment on alternatives for Rust, that
pointed me to D.)
2. I am also curious as to what would
I get a segmentation fault, when I run this program:
void main()
{
A bar = cast(A)Object.factory("AA");
bar.foo();
}
class A{ abstract void foo(); }
class AA:A { override void foo() {} }
The call of bar.foo() is, where the segmentation fault occurs.
When I use A bar = new AA(); ins
On Sunday, 19 February 2017 at 10:15:49 UTC, rikki cattermole
wrote:
What's wrong here?
void main()
{
A bar = cast(A)Object.factory(__MODULE__ ~ ".AA");
bar.foo();
}
Oops. I overdid when trying to create a small example. With the
module it works, but my original program had the module
Is it possible to force a function to be inlined?
Comparing a C++ and a D program, the main difference in speed
(about 20-30%) is, because I manage to force g++ to inline a
function while I do not find any means to do the same on D.
On Sunday, 19 February 2017 at 20:00:00 UTC, Daniel Kozak wrote:
Dne 19.2.2017 v 20:19 berni via Digitalmars-d-learn napsal(a):
Is it possible to force a function to be inlined?
Comparing a C++ and a D program, the main difference in speed
(about 20-30%) is, because I manage to force g++ to
1 - 100 of 111 matches
Mail list logo