On Sunday, 2 February 2014 at 15:31:30 UTC, Russel Winder wrote:
result is:
|> LD_LIBRARY_PATH=. python execute.py
Segmentation fault
You should call Runtime.initialize() prior to calling any other D
functions.
It seems to me that worker threads will continue as long as
the queue isn't empty. So if a task adds another task to the
pool, some worker will process the newly enqueued task.
No. After taskPool.finish() no way to add new tasks to the
queue. taskPool.put will not add new tasks.
Then perhaps
On Monday, 3 February 2014 at 10:25:19 UTC, Chris wrote:
Is there a way I can make the return type in getAttribute
generic? null does not work with numbers.
MyStruct(T) {
T[T] attributes;
//
public auto getAttribute(T attr) {
if (!(attr in attributes)) {
return null; //
On Monday, 3 February 2014 at 23:50:54 UTC, bearophile wrote:
Rene Zwanenburg:
The problem is speed. I'm using LockingTextReader in
std.stdio, but it't not nearly fast enough. On my system it
only reads about 3 MB/s with one core spending all it's time
in IO calls.
Are you reading the text
Rene Zwanenburg:
The problem is speed. I'm using LockingTextReader in std.stdio,
but it't not nearly fast enough. On my system it only reads
about 3 MB/s with one core spending all it's time in IO calls.
Are you reading the text by lines? In Bugzilla there is a
byLineFast:
https://d.puremag
I'm running into a problem I've come across before but never
found a satisfactory solution for.
There's a pretty large ascii file I need to process, currently
about 3GB but size will increase in the future. D's ranges in
combination with std.algorithm are simply perfect for what I'm
doing, an
On Monday, 3 February 2014 at 20:10:59 UTC, Brenton wrote:
4) Is it advisable for the cross method to return by value? In
C++, I would declare this method as inline and in a header
file. Can I trust D to inline away this inefficiency? Perhaps
I should pass in the result as a "ref" or "out"
On Monday, 3 February 2014 at 20:10:59 UTC, Brenton wrote:
double dot(in Vector3d other) inout {
return x * other.x + y * other.y + z * other.z;
}
Vector3d cross(in Vector3d other) inout {
const Vector3d result = {
y
5) I notice that a lot of other people online prefer using
fixed arrays not structs for Vectors in D, why?
It does make some calculations more straightforward. For example
I have code that calculates distance between points as follows:
double euclideanDistance( double[] pt1, double[] pt2 ) in
Brenton:
1) I initialize the vector to a null vector, not nans
Why?
2) The dot and cross are "inout" methods, i.e. available for
mutable, const, and immutable objects. There is no reason to
declare "inout" methods as being "const".
But I suggest to add pure/nothrow.
3) The dot and cro
Hi, I'm just getting to know D and so am hoping that someone more
experienced with the language could review this 3d vector struct
and my comments below. I'm planning on building a little ray
tracer in the next week or so :)
struct Vector3d {
double x = 0, y = 0, z = 0;
void
On Monday, 3 February 2014 at 19:35:47 UTC, Andre wrote:
Btw. having std.decimal in the library would be really nice;)
Kind regards
André
There is a proposal in Phobos review queue
(http://wiki.dlang.org/Review_Queue) but its author does not seem
to be active anymore so it moves nowhere.
Am 03.02.2014 20:09, schrieb Ali Çehreli:
On 02/03/2014 10:15 AM, Andre wrote:
>
> I want to check whether the value stored in
> variant v is a type of Decimal during runtime.
> Is there a nice way?
>
> Kind regards
> André
>
> import std.variant;
>
> struct Decimal(int scale, int prec
On 02/03/2014 10:15 AM, Andre wrote:
>
> I want to check whether the value stored in
> variant v is a type of Decimal during runtime.
> Is there a nice way?
>
> Kind regards
> André
>
> import std.variant;
>
> struct Decimal(int scale, int precision){
> int _precision = precision;
> int
(you can check for specific type via `v.type() ==
typeid(Decimal!(10,2))` though)
No. Variant only stores TypeInfo for its current data and
templated struct will have a totally different type for each set
of template arguments. Their similarity exists only during
compile-time.
On Monday, 3 February 2014 at 17:58:43 UTC, Namespace wrote:
On Monday, 3 February 2014 at 17:50:33 UTC, Martin wrote:
On Monday, 3 February 2014 at 17:43:09 UTC, Namespace wrote:
On Monday, 3 February 2014 at 17:32:07 UTC, Martin wrote:
Oops, I of course meant:
static Test createFromString(s
Hi,
I want to check whether the value stored in
variant v is a type of Decimal during runtime.
Is there a nice way?
Kind regards
André
import std.variant;
struct Decimal(int scale, int precision){
int _precision = precision;
int _scale = scale;
this(string value){/*...
On Monday, 3 February 2014 at 17:50:33 UTC, Martin wrote:
On Monday, 3 February 2014 at 17:43:09 UTC, Namespace wrote:
On Monday, 3 February 2014 at 17:32:07 UTC, Martin wrote:
Oops, I of course meant:
static Test createFromString(string str)
{
return new Test(str);
}
You _can_ use scoped bu
On Monday, 3 February 2014 at 17:43:09 UTC, Namespace wrote:
On Monday, 3 February 2014 at 17:32:07 UTC, Martin wrote:
Oops, I of course meant:
static Test createFromString(string str)
{
return new Test(str);
}
You _can_ use scoped but it may allocate way to much and it's
ugly to use:
http
On Monday, 3 February 2014 at 17:32:07 UTC, Martin wrote:
Oops, I of course meant:
static Test createFromString(string str)
{
return new Test(str);
}
You _can_ use scoped but it may allocate way to much and it's
ugly to use:
http://dlang.org/phobos/std_typecons.html#.scoped
AFAIK scope'd
Oops, I of course meant:
static Test createFromString(string str)
{
return new Test(str);
}
Seeing as the scope keyword is (being?) deprecated, how would you
handle something like this:
class Test
{
private:
string str;
this(string str)
{
this.str = str;
}
public:
static Test createFromString(string str)
{
return new Test();
}
}
void main()
{
// at the end
On Monday, 3 February 2014 at 14:10:35 UTC, bearophile wrote:
Dicebot:
If you need cheap and simple way to figure out that attribute
was missing, change API to return value by out parameter and
turn normal return value into boolean success flag.
It's probably better to start using Nullable.
On Monday, 3 February 2014 at 14:17:11 UTC, Chris wrote:
Probably. I tried using Nullable, but it caused some problems
when the attribute wasn't defined:
core.exception.AssertError@/usr/include/dmd/phobos/std/typecons.d(1233):
Called `get' on null Nullable!int.
This is intended. The very poi
On Monday, 3 February 2014 at 14:21:29 UTC, Dicebot wrote:
On Monday, 3 February 2014 at 14:17:11 UTC, Chris wrote:
Probably. I tried using Nullable, but it caused some problems
when the attribute wasn't defined:
core.exception.AssertError@/usr/include/dmd/phobos/std/typecons.d(1233):
Called
On Monday, 3 February 2014 at 14:21:29 UTC, Dicebot wrote:
This is intended. The very point of Nullable is to force you to
handle `null` state before accessing actual payload.
P.S. for this very reason in my own implementation of Optional I
provide only delegate access method:
value.get(
On Monday, 3 February 2014 at 14:10:35 UTC, bearophile wrote:
Dicebot:
If you need cheap and simple way to figure out that attribute
was missing, change API to return value by out parameter and
turn normal return value into boolean success flag.
It's probably better to start using Nullable.
Dicebot:
If you need cheap and simple way to figure out that attribute
was missing, change API to return value by out parameter and
turn normal return value into boolean success flag.
It's probably better to start using Nullable.
Bye,
bearophile
On Monday, 3 February 2014 at 12:25:16 UTC, Dicebot wrote:
You have forgot to mention what behavior you are actually
trying to achieve ;) Common not-so-meaningful value is simply
T.init , but there can be no such thing as generic sentinel.
If you need cheap and simple way to figure out that at
You have forgot to mention what behavior you are actually trying
to achieve ;) Common not-so-meaningful value is simply T.init ,
but there can be no such thing as generic sentinel.
If you need cheap and simple way to figure out that attribute was
missing, change API to return value by out para
On Monday, 3 February 2014 at 10:55:23 UTC, Chris wrote:
I'm reluctant to (over)use throw, because I think that throw
should be the last resort when you cannot easily predict all
the things that can go wrong. Simple requests should give
simple answers. If the key doesn't exist it returns nothi
On Monday, 3 February 2014 at 10:32:58 UTC, Stanislav Blinov
wrote:
On Monday, 3 February 2014 at 10:25:19 UTC, Chris wrote:
T[T] attributes;
//
public auto getAttribute(T attr) {
if (!(attr in attributes)) {
return null; // Doesn't work for numbers!
}
return attri
On Monday, 3 February 2014 at 10:25:19 UTC, Chris wrote:
T[T] attributes;
//
public auto getAttribute(T attr) {
if (!(attr in attributes)) {
return null; // Doesn't work for numbers!
}
return attributes[attr];
}
}
One way would be to use std.typecons.Nu
Is there a way I can make the return type in getAttribute
generic? null does not work with numbers.
MyStruct(T) {
T[T] attributes;
//
public auto getAttribute(T attr) {
if (!(attr in attributes)) {
return null; // Doesn't work for numbers!
}
return attributes
35 matches
Mail list logo