Is this a bug? I'm very puzzled; it seems that the destructor
for struct mystruct is called pre-maturely. It should be after
the 'in call(): X 12, Y 0, Z 9 line, should it not?
Using DMD64 D Compiler v2.062 on OSX 10.6.8 and Linux x86_64
Output is:
$ dmd -run named14.d
start of main
in
--no-as-needed ... (which is
painful, hence the #1 step above is vastly preferred)
but somebody smarter than me should probably have a look at the
linking in the 'make check' for D's thrift bindings and try to
make it work even without --no-as-needed.
-J
hi,
can anybody tell me please why the linker keeps bringing up this error
message? i am using the latest dmd 2.
thank you
OPTLINK (R) for Win32 Release 8.00.2
Copyright (C) Digital Mars 1989-2009 All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
obj\Debug\SServer.obj(SServer)
Hi,
It's been a while since I've used CTFE, and I was wondering if it has
become possible to do something like this:
void ctfeFunc(string arg)
{
pragma(msg, arg is ~arg);
}
void main()
{
ctfeFunc(foo);
}
That specific attempt gives me an error:
test.d(3): Error: variable
On 05/13/2012 03:32 AM, Dmitry Olshansky wrote:
On 13.05.2012 6:07, Chad J wrote:
I want some way to print out the state of variables in a function being
executed at compile time. Can it be done?
Try pulling this guy (aka __ctfeWrite):
https://github.com/D-Programming-Language/dmd/pull/692
http://dlang.org/phobos/std_array.html#splitter
The first thing I don't understand is why splitter is in /std.array/ and
yet only works on /strings/. It is defined in terms of whitespace, and
I don't understand how whitespace is well-defined for things besides
text. Why wouldn't it be in
I'm realizing that if I want to remove exactly one line from a string of
text and make no assumptions about the type of newline (\n or \r\n
or \r) and without scanning the rest of the text then I'm not sure how
to do this with a single call to phobos functions. I'd have to use
indexOf and do
On 06/23/2012 11:31 AM, simendsjo wrote:
On Sat, 23 Jun 2012 17:19:59 +0200, Chad J
chadjoan@__spam.is.bad__gmail.com wrote:
http://dlang.org/phobos/std_array.html#splitter
The first thing I don't understand is why splitter is in /std.array/
and yet only works on /strings/. It is defined
On 06/23/2012 11:44 AM, simendsjo wrote:
On Sat, 23 Jun 2012 17:39:55 +0200, Chad J
chadjoan@__spam.is.bad__gmail.com wrote:
On 06/23/2012 11:31 AM, simendsjo wrote:
On Sat, 23 Jun 2012 17:19:59 +0200, Chad J
chadjoan@__spam.is.bad__gmail.com wrote:
http://dlang.org/phobos/std_array.html
On 06/23/2012 01:02 PM, simendsjo wrote:
On Sat, 23 Jun 2012 18:56:24 +0200, simendsjo simend...@gmail.com wrote:
On Sat, 23 Jun 2012 18:50:05 +0200, Chad J
chadjoan@__spam.is.bad__gmail.com wrote:
Looking for findSplit?
http://dlang.org/phobos/std_algorithm.html#findSplit
Cool, that's what
On 06/23/2012 01:24 PM, Chad J wrote:
On 06/23/2012 01:02 PM, simendsjo wrote:
On Sat, 23 Jun 2012 18:56:24 +0200, simendsjo simend...@gmail.com
wrote:
On Sat, 23 Jun 2012 18:50:05 +0200, Chad J
chadjoan@__spam.is.bad__gmail.com wrote:
Looking for findSplit?
http://dlang.org/phobos
On 06/23/2012 02:17 PM, simendsjo wrote:
On Sat, 23 Jun 2012 19:52:32 +0200, Chad J
chadjoan@__spam.is.bad__gmail.com wrote:
As an additional note: I could probably do this easily if I had a
function like findSplit where the predicate is used /instead/ of a
delimiter. So like this:
auto
On 06/23/2012 02:53 PM, simendsjo wrote:
On Sat, 23 Jun 2012 20:41:29 +0200, Chad J
chadjoan@__spam.is.bad__gmail.com wrote:
Hey, thanks for doing all of that. I didn't expect you to write all of
that.
np
Once I've established that the issue isn't just a lack of learning on
my part, my
On 06/23/2012 03:41 PM, simendsjo wrote:
On Sat, 23 Jun 2012 20:41:29 +0200, Chad J
chadjoan@__spam.is.bad__gmail.com wrote:
IMO the take away a single line thing should be accomplishable with
a single concise expression
This takes a range to match against, so much like startsWith:
auto
I keep hearing that scope variables are going away. I missed the
discussion on it. Why is this happening?
When I read about this, I have these in mind:
void someFunc()
{
// foo is very likely to get stack allocated
scope foo = new SomeClass();
foo.use();
//
On 07/26/2012 09:19 PM, Jonathan M Davis wrote:
On Thursday, July 26, 2012 21:09:09 Chad J wrote:
I keep hearing that scope variables are going away. I missed the
discussion on it. Why is this happening?
When I read about this, I have these in mind:
void someFunc()
{
// foo is very
Is there some way to do something similar to this right now?
void main()
{
// Differing levels of type-inference:
int[] r1 = [1,2,3]; // No type-inference.
Range!(int) r2 = [1,2,3]; // Only range kind inferred.
Range r3 = [1,2,3]; // Element type inferred.
autor4 =
On 07/28/2012 03:03 AM, Jonathan M Davis wrote:
On Saturday, July 28, 2012 02:49:16 Chad J wrote:
Is there some way to do something similar to this right now?
void main()
{
// Differing levels of type-inference:
int[] r1 = [1,2,3]; // No type-inference.
That works just fine
On 07/28/2012 04:55 PM, Jonathan M Davis wrote:
On Saturday, July 28, 2012 16:47:01 Chad J wrote:
range kind is informal language. Maybe I mean template instances,
but that would somewhat miss the point.
I don't know how to do this right now. AFAIK, it's not doable.
When I speak of ranges I
On 07/28/2012 05:55 PM, Jonathan M Davis wrote:
On Saturday, July 28, 2012 17:48:21 Chad J wrote:
I suppose that works, but it isn't very consistent with how type safety
is normally done. Also it's extremely verbose. I'd need a lot of
convincing to chose a language that makes me write stuff
On 07/29/2012 08:32 AM, Simen Kjaeraas wrote:
On Sat, 28 Jul 2012 22:47:01 +0200, Chad J
chadjoan@__spam.is.bad__gmail.com wrote:
isInputRange!___ r2 = [1,2,3].some.complex.expression();
It doesn't make sense. isInputRange!() isn't a type, so how do I
constrain what type is returned from
On 07/29/2012 11:54 AM, Ali Çehreli wrote:
On 07/28/2012 01:47 PM, Chad J wrote:
What I want to do is constrain that the type of r3 is some kind of
range. I don't care what kind of range, it could be a range of integers,
a range of floats, an input range, a forward range, and so on. I
std.file seems to have a getAttributes function, but I see no
corresponding setAttributes function. What do I do if I want to copy
the attributes from one file to another?
On 07/29/2012 04:55 PM, Jonathan M Davis wrote:
On Sunday, July 29, 2012 16:47:50 Chad J wrote:
std.file seems to have a getAttributes function, but I see no
corresponding setAttributes function. What do I do if I want to copy
the attributes from one file to another?
std.file does
In Dr Alexandrescu's The D Programming Language, on page 12, it
is noted that the D compiler will rewrite tail calls within a
procedure as loops. Does the compiler rewrite tail calls between
procedures as jumps?
For example, in pseudo-D:
void foo(K)(K cont, stuff..) {
// Do things with
On 11/05/2013 11:00 AM, bearophile wrote:
How to solve such little troubles? A possible idea is to add to D
another attribute, a kind of private private that is enforced inside
the same module. It could be named super private because D has the
super keyword :-) But this idea doesn't solve all
On 10/31/2013 04:36 PM, Jacob Carlborg wrote:
On 2013-10-31 14:47, ilya-stromberg wrote:
John, It's interesting if you can connect to the MS SQL.
Just use FreeTDS, nothing special about it. See:
On 11/06/2013 02:36 AM, Jacob Carlborg wrote:
On 2013-11-06 08:28, John J wrote:
Thanks Jacob,
I guess I have to compile and distribute a FreeTDS.dll, and it only
works for win32
FreeTDS works on Posix platforms. I wrote that code on Mac OS X. We use
FreeTDS in production, running servers
On 11/06/2013 02:36 AM, Jacob Carlborg wrote:
On 2013-11-06 08:28, John J wrote:
Thanks Jacob,
I guess I have to compile and distribute a FreeTDS.dll, and it only
works for win32
FreeTDS works on Posix platforms. I wrote that code on Mac OS X. We use
FreeTDS in production, running servers
Can you please add the D language to the http://learnxinyminutes.com/
That's an interesting way of quickly introducing a language through a
long and well commented code example.
There are several other languages on that site already but the D is missing.
== Quote from Joel Christensen (joel...@gmail.com)'s article
I noticed in windows with D you can use .res (eg. dmd main.d smile.res)
files for icons any way. but how do you make icon .res files?
With a resource compiler. Digital Mars supplies one as part of its C++
utilities package:
== Quote from Tyro[a.c.edwards] (nos...@home.com)'s article
Both implementations results in error code 1812 being returned from
GetLastError. explanation of the code reads:
ERROR_RESOURCE_DATA_NOT_FOUND
1812 (0x714)
The specified image file did not contain a resource
Let's say I have a class template whose type parameter will be drawn from a
small, fixed-ahead-of-time set of types, but which type won't be known until
runtime. For example, say I would like to operate on a vector of
floating-point values read in from disk, but I won't know if it will be a
Daniel Keep Wrote:
The major problem with this is that you're trying to get into a
situation where you don't know the type of T at compile-time, and you
CANNOT do that.
Exactly -- I have been using Python lately. :) But wouldn't it be nice to have
something like implicit template
Hmm, not quite.
This works at runtime, but not at compile-time; I can't use classes at compile
time:
http://www.digitalmars.com/d/2.0/function.html#interpretation
and TypeInfo is a class:
http://www.digitalmars.com/d/2.0/phobos/object.html#TypeInfo
Basically, what I want to do is
grauzone Wrote:
What exactly are you trying to accomplish?
It seems that you want to use the AA in CTFE, but it doesn't work,
because using AAs with classes as keys don't work in CTFE?
Correct. At compile time, I want to build up an associative array mapping type
tuples to integers.
I want to test whether a struct member is a real field or a property at compile
time. I thought this is what is(type == function) is supposed to do, but I
can't find anything that will make is(type == function) true. What am I doing
wrong?
--
Answered my own question:
static if (is(typeof(func0) == function))
writefln(func0 is a function.);
is() really wants a type, not an expression.
OK, here's one for you that sounds like it ought to be easy, but I don't
immediately see how to do it in a pretty way.
Given a type parameter T of a template:
If T is an integral type, I want to declare a variable 'widest' of type ulong;
If T is a floating-point type, I want to declare a
Taken straight from http://www.digitalmars.com/d/1.0/arrays.html, this doesn't
compile:
void main()
{
string str = abc;
char* p = str; // pointer to 1st element
}
Error: cannot implicitly convert expression (str) of type char[] to char*
I agree it shouldn't
I want to write an interface that expresses the following idea: classes
implementing this interface must have a void function named update, with a
fixed but indeterminate number of parameters of the same (template parameter)
type. In other words, some implementing classes will have void
Regarding template mixins, I'm curious, why is the decision to mixin a
template made at the call site and not at the declaration of the
template/mixin?
In other words, why do we write
template foo()
{
// etc..
}
mixin foo!();
instead of
Bill Baxter wrote:
On Fri, Aug 21, 2009 at 10:36 AM, div0d...@users.sourceforge.net wrote:
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Not sure what the original choice was based on, but what you suggest
looks wrong to me. You aren't necessarily using a template in order to
mix it in
Max wrote:
Is there any way in Phobos to measure the current time with microsecond
accuracy?
Max
Might I suggest std.perf?
I found it here some years ago:
http://www.digitalmars.com/techtips/timing_code.html
It even seems to have survived the transition from D1 to D2.
Oddly enough, this
Given an Expression object in dmd, I'd like to know how many
subexpressions it contains and, even better, iterate over them. I'd
like to do this in a general way, without having to create cases for all
of the different kinds of Expressions. Is there some way to do this
that I've been missing?
Ellery Newcomer wrote:
On 11/30/2009 03:53 AM, Ary Borenszweig wrote:
Chad J wrote:
Given an Expression object in dmd, I'd like to know how many
subexpressions it contains and, even better, iterate over them. I'd
like to do this in a general way, without having to create cases for all
I think I'll reply to both of you in one post since the thoughts are
related.
Ary Borenszweig wrote:
Ellery Newcomer wrote:
Not that I know anything about DMD outside parse.c, but in
expression.h, there be decls along the lines of
struct UnaExp{
Expression* e1;
}
struct BinExp{
Ellery Newcomer wrote:
On 11/30/2009 07:59 PM, Chad J wrote:
This is about the property expression rewrite of course. I'd love to
just use the current convention in dmd and write the rewrite as a
non-recursive function that gets called at every point in the tree
whenever someExpr-semantic
Hello. When I'm trying to create a class object by using a
dlsym-ed function, I'm getting a segmentation fault after
execution of program.
However, if I'm deleting that object before 'return 0' in main
(by using 'delete b'), everything is going fine.
I'm just started to learn D after using
What am I doing wrong here? Is there any way to do what I'm
trying to do
right way?
Dynamic libraries aren't properly supported by the runtime.
That's terrible:(
It's so nice to make an interface, and create classes that
inherit this interface dynamically, without linking...
Maybe
Thank you for your replies!
I've found a working solution - all I needed is to change wstring
to const wstring, and pass it not as func(something), but as
wstring tmp = something; func(tmp);
That's really odd, because I don't understand, how those changes
made segfault disappear.
Here's
On Saturday, 29 June 2013 at 06:08:28 UTC, Jeremy DeHaan wrote:
I've been toying around with the idea of working on an IDE,
mostly because I think it would be an interesting/fun project
to work on. In any case, the only thing I cannot seem to wrap
my head around is how programs like Code
Hi,
I don't want to keep typing isNumeric!T | isSomeChar!T. I want to type
isBuiltIn!T instead, but am trying to work out how to implement it.
Something like
template isBuiltInT(T) {const bool t=isNumeric!T | isSomeChar!T};}
alias isBuiltInT.t isBuiltIn;
But that doesn't compile. How should
On Tuesday, 13 December 2022 at 19:28:44 UTC, Leonardo A wrote:
Hello. How to use version in dub?
https://dlang.org/spec/version.html
"The version level and version identifier can be set on the
command line by the -version"
I tried everything but noting.
Look for a file called dub.json.
On Thursday, 8 December 2022 at 16:55:34 UTC, johannes wrote:
/we-/we/sqlite3/package.d(121): Error: semicolon expected
following auto declaration, not `32`
/we-/we/sqlite3/package.d(121): Error: declaration expected,
not `32`
/we-/we/sqlite3/package.d(122): Error: semicolon expected
following
On Saturday, 19 November 2022 at 14:07:59 UTC, Nick Treleaven
wrote:
Hi,
The following seems like a bug to me (reduced code, FILE*
changed to int*):
```d
@safe:
struct LockedFile
{
private int* fps;
auto fp() return scope => fps;
}
void main()
{
int* p;
{
auto lf =
On Sunday, 18 December 2022 at 17:05:45 UTC, Sergey wrote:
On Friday, 16 December 2022 at 20:57:30 UTC, Dariu Drew wrote:
Hi! i need help in can i create a serve API, what library i
should use? what documentation i should read?
Check the bench: https://github.com/tchaloupka/httpbench
there
On Sunday, 18 December 2022 at 16:21:05 UTC, Salih Dincer wrote:
Don't you think it's interesting that it doesn't need unary
operator overloading?
```d
import std.stdio;
struct S
{
int value;
alias opCall this;
this(int i) {
value = i;
}
alias opAssign = opCall;
@property
On Friday, 16 December 2022 at 12:17:40 UTC, Nick Treleaven wrote:
This code segfaults when the GC calls the dtor after the
unittest succeeds:
```d
unittest
{
int i;
struct S
{
~this() { i++; }
}
(*new S).destroy;
}
```
It seems destroy clears the context pointer.
On Sunday, 18 December 2022 at 16:17:40 UTC, Salih Dincer wrote:
On Saturday, 10 December 2022 at 11:13:57 UTC, Nick Treleaven
wrote:
It was bizarre and confusing that assignment syntax was
implemented for functions and methods not explicitly marked
with @property.
Hi Nick, do you think this
On Thursday, 15 December 2022 at 21:43:07 UTC, TheZipCreator
wrote:
is there a compiled binary of GDC anywhere? I looked at
https://www.gdcproject.org/downloads, and the link there goes
to winlibs, but after downloading the archive I couldn't find
gdc anywhere in it. I did some research and
On Saturday, 10 December 2022 at 05:46:26 UTC, thebluepandabear
wrote:
In most languages there is some sort of `List` type, is that
the same for D?
What you're probably talking about is called a union in the C
world. There is a nice (free) book by Ali that every Dlang
beginner should
On Monday, 19 December 2022 at 04:26:39 UTC, Salih Dincer wrote:
On Sunday, 18 December 2022 at 21:17:02 UTC, j wrote:
Why are you using `@property` everywhere?
You are right but if I don't use it for `opCall()` the output
will be like `S(9)`. Likewise, if I don't use `inout`, the
program
On Monday, 19 December 2022 at 03:31:05 UTC, thebluepandabear
wrote:
On Sunday, 18 December 2022 at 22:17:04 UTC, j wrote:
On Saturday, 10 December 2022 at 05:46:26 UTC,
thebluepandabear wrote:
In most languages there is some sort of `List` type, is
that the same for D?
What you're
On Monday, 19 December 2022 at 04:26:39 UTC, Salih Dincer wrote:
On Sunday, 18 December 2022 at 21:17:02 UTC, j wrote:
Why are you using `@property` everywhere?
You are right but if I don't use it for `opCall()` the output
will be like `S(9)`. Likewise, if I don't use `inout`, the
program
On Saturday, 17 December 2022 at 00:23:32 UTC, thebluepandabear
wrote:
I am reading the fantastic book about D by Ali Çehreli, and he
gives the following example when he talks about variadic
functions:
```D
int[] numbersForLaterUse;
void foo(int[] numbers...) {
numbersForLaterUse =
On Saturday, 17 December 2022 at 02:42:22 UTC, Paul wrote:
I see code like this from time to time. Are the leading
underscores significant, in general, in the D language? Is it
just programmer preference? Is it a coding practice, in
general, that is common...even outside of D? Thanks for
On Wednesday, 14 December 2022 at 11:30:07 UTC, Vitaliy Fadeev
wrote:
Hi! I open a device under Windows:
```
HANDLE h = CreateFileW( ... );
```
in procedure:
```
HANDLE open_keyboard_device2( LPCWSTR path, int* error_number )
{
...
HANDLE dev_handle =
CreateFileW(
On Monday, 12 December 2022 at 17:23:36 UTC, lili wrote:
```
int[string] aa = ["ok":1, "aaa":2, "ccc":3, "ddd":4];
foreach (k ; aa.byKey)
{
if (k == "aaa") {
aa.remove(k);
aa["ww"] = 33;
}
if (k ==
On Saturday, 3 December 2022 at 18:59:58 UTC, zoujiaqing wrote:
```
dub build --compiler=ldc2 --arch=arm64-apple-macos
Starting Performing "debug" build using ldc2 for aarch64,
arm_hardfloat.
Building taggedalgebraic 0.11.22: building configuration
[library]
Building eventcore
On Thursday, 2 July 2015 at 12:59:03 UTC, Steven Schveighoffer
wrote:
On 7/2/15 8:21 AM, Marc =?UTF-8?B?U2Now7x0eiI=?=
schue...@gmx.net wrote:
On Thursday, 2 July 2015 at 10:48:56 UTC, Steven Schveighoffer
wrote:
On 7/1/15 8:36 PM, J Miller wrote:
Oh, and to make things really confusing, auto
On Wednesday, 1 July 2015 at 21:15:13 UTC, Marc Schütz wrote:
On Wednesday, 1 July 2015 at 19:09:36 UTC, Alex Parrill wrote:
I don't think this is a bug.
Since you don't initialize `c` to anything, it defaults to an
empty slice. Array [] operations apply to each element of a
slice, but `c`
Hi, folks. Over ten years ago I had some interest in the D
language. I'm starting to think about it again...
I've been using Mozilla's Promises implementations for quite a
while, now, and they're surprisingly nice to work with. They are
the next generation beyond the callback function
On Thursday, 20 August 2015 at 01:10:39 UTC, Alex Parrill wrote:
IMO the 'next' generation of async is fibers/coroutines, not
promises. Vibe.d is a great example; the code looks exactly
like a normal synchronous function (including try/catch!), but
is asynchronous behind the scenes.
See
A hack is to create the gc code you in a function want to call,
say does the "gc" opEquals. Then cast that function to a nogc
version by first casting to a void*. This way you can call gc
code from nogc code, by bypassing the compiler's ability to
check. It will obviously break your code if
winmain.d(40): Error: found 'while' when expecting ';' following
statement
winmain.d(40): Error: unexpected ( in declarator
winmain.d(40): Error: basic type expected, not &
winmain.d(40): Error: found '&' when expecting ')'
winmain.d(40): Error: found 'msg' when expecting ')'
winmain.d(40):
On Thursday, 4 August 2016 at 21:03:52 UTC, Mark "J" Twain wrote:
How can I construct a va_list for vsprintf when all I have is
the a list of pointers to the data, without their type info?
A va_list seems to be a packed struct of values and/or pointers
to the data. While I could
How can I construct a va_list for vsprintf when all I have is the
a list of pointers to the data, without their type info?
A va_list seems to be a packed struct of values and/or pointers
to the data. While I could construct such a list, theoretically,
I don't always know when I should store
On Friday, 5 August 2016 at 08:32:42 UTC, kink wrote:
On Thursday, 4 August 2016 at 21:03:52 UTC, Mark "J" Twain [...]
This has absolutely nothing to do with D as these are C
functions, so you'd be better off asking this in another forum.
Um, then I wonder why I am using D? Why d
I use malloc to allocate some memory, then free it later. For
monitoring purposes, I would like to know how much is free'ed by
free by just knowing the object. Or, rather, given a ptr
allocated by malloc, bet the block size it allocated from the ptr
alone.
Some C compilers have special
On Friday, 5 August 2016 at 20:43:12 UTC, H.Loom wrote:
On Friday, 5 August 2016 at 19:55:22 UTC, Mark "J" Twain wrote:
[...]
You can wrap the C memory allocations functions with a version
identifier, e.g
version(stat)
{
__gshared size_t[size_t] sizes;
}
version(stat)
Any solution out there that can get call stack, file and line
info? Similar to exceptions but I simply want to track memory
allocations and need the complete call stack rather than just the
previous call(using __FUNCTION__/__FILE__/etc), which is usually
useless.
Of course, exceptions have
On Saturday, 6 August 2016 at 01:44:04 UTC, Adam D. Ruppe wrote:
On Saturday, 6 August 2016 at 01:29:37 UTC, Mark "J" Twain
wrote:
Of course, exceptions have TraceInfo... could that be used
anywhere or hacked to get what I need?
The function is defaultTraceHandler in druntim
It's nice to be able to pass delegates and functions as callbacks.
A nice feature is something like
R foo(R,Args...)(R function(Args) callback, Args args) { return
callback(args); }
There are two problems with this.
One is that type deduction doesn't work. I have to explicitly
specify the
On Wednesday, 3 August 2016 at 08:12:00 UTC, Ali Çehreli wrote:
On 08/02/2016 07:55 PM, Mark J Twain wrote:
[...]
I didn't know one could use 'auto ref' in this case but the
following simple test works:
auto foo(Func, Args...)(Func callback, auto ref Args args) {
return callback(args
Say I have a project with the files structured like this.
package-name/
src/
package-name/
lib.d
test/
testlib.d
How do I make it so that I can import and use the contents of
lib.d inside of testlib.d.
As you can tell I'm very new to D, and kind of new to
I'm not sure if it's what happening in this case but, in code
as simple as this, function calls can sometimes be the
bottleneck. You should see how compiling with/without -O
affects performance, and adding `pragma(inline)` to funcB.
I guess my question is whether it is possible to have
Let's say I want to create an array of random numbers and do some
operations on them:
void main() {
import std.random;
//Generate array of random numbers
int arrSize = 1;
double[] arr = new double[](arrSize);
foreach (i; 0..arrSize)
arr[i] = uniform01();
I'm not sure if it's what happening in this case but, in code
as simple as this, function calls can sometimes be the
bottleneck. You should see how compiling with/without -O
affects performance, and adding `pragma(inline)` to funcB.
When compiled with -inline, the profiler does not report the
I have translated some simulation code from Java into D (a few
classes, mostly manipulation of double arrays in small methods).
D version runs 10-30% slower than Java (ldc2, dub release build).
Profiling did not show any obvious bottlenecks. I am wondering
whether I missed something, or such
Without seeing the source there is nothing we can do.
Usually performant d-code looks quite diffrent from java code.
For example to avoid the gc :)
Well it is actually ODE solver from Numerical recipes (originally
in C++) that I am trying to do in D. Code translation seems very
On Monday, 30 January 2017 at 00:17:51 UTC, ag0aep6g wrote:
Removing works by overwriting the array with only the wanted
values and discarding the rest.
But then why do I get this:
import std.stdio, std.algorithm, std.array;
int[] arr;
foreach (i; 0..10) arr ~= i; // [0, 1, 2,
On Monday, 30 January 2017 at 12:31:33 UTC, albert-j wrote:
OK, got it. Can you do removal without reallocation with
std.container.array?
Array!int arr;
foreach (i; 0..10) arr ~= i;
Sorry, sent too early.
arr = arr[].remove!(x=> x > 5); //Doesn't work withouth
calling
On Monday, 30 January 2017 at 10:45:03 UTC, cym13 wrote:
Meh.
Forget that, bad memory. remove isn't working in-place. However
slapping ".array" is still asking explicitely for reallocation,
so just forget it. Here is a code that works:
import std.conv;
import std.stdio;
import std.format;
On Friday, 27 January 2017 at 08:15:56 UTC, Dukc wrote:
void main()
{ import std.stdio, std.algorithm, std.range, std.array,
std.datetime;
int[] a = [1, 2, 3, 4, 5, 6, 7, 4].cycle.take(2000).array;
int[] b = [3, 4, 6].cycle.take(2000).array;
void originalMethod()
{ auto c
On Saturday, 28 January 2017 at 11:54:58 UTC, cym13 wrote:
I am trying to wrap my head around lazy evaluation during
filtering/mapping, but there's something I don't understand.
I want to create an array, square some elements, remove some
elements from original array and add the squared
On Sunday, 29 January 2017 at 23:48:40 UTC, Jordan Wilson wrote:
You need to do something like this:
auto arrMap = arr.filter!(x => x > 5).map!(x => x^^2).array;
It's because arrMap is lazy evaluated.
So does it mean that I cannot assign FilterResult and MapResult
to a variable and safely
On Monday, 30 January 2017 at 00:17:51 UTC, ag0aep6g wrote:
[...]
Great explanation, thank you!
What is the D idiom for removing array elements that are present
in another array?
Is this the right/fastest way?
int[] a = [1, 2, 3, 4, 5, 6, 7, 4];
int[] b = [3, 4, 6];
auto c = a.remove!(x => b.canFind(x));
assert(c == [1, 2, 5, 7]);
In anycase, what is the correct notation for indexing?
x = new int[][](width, height)
and x[height][width] or x[width][height]?
It's x[width][height], but because indexing is 0-based, largest
valid indexes are
x[width-1][height-1].
1 - 100 of 122 matches
Mail list logo