Hello, i am new to D language and trying to learn it by coding.
I compile my programs on Xubuntu 14.04 with DMD64 D Compiler
v2.069.2.
So i have a struct/union which contains two fields representing
real and string values:
public union Element
{
private real _value;
private
On Wednesday, 6 January 2016 at 01:41:03 UTC, Basile B. wrote:
Until a certain "time" my answers were useful. But I recognize
that after this "time" I've managed to turn the topic into
something totally delirious because, to be honest I was
completly sratched by alcohool. I'm sorry but life is
On Wednesday, 6 January 2016 at 13:36:03 UTC, data pulverizer
wrote:
I have been converting C numeric libraries and depositing them
here: https://github.com/dataPulverizer. So far I have glpk and
nlopt converted on a like for like c function basics. I am now
stuck on the gsl library, primarily
At
https://github.com/D-Programming-Language/phobos/pull/3752
it would be nice if
return !haystack.empty && haystack.front.unaryFun!pred
was made nothrow.
Is this possible somehow?
On Wednesday, 6 January 2016 at 11:39:44 UTC, Voitech wrote:
Hello, i am new to D language and trying to learn it by coding.
I compile my programs on Xubuntu 14.04 with DMD64 D Compiler
v2.069.2.
So i have a struct/union which contains two fields representing
real and string values:
public
On Wednesday, 6 January 2016 at 12:25:31 UTC, Nicholas Wilson
wrote:
Probably because you are accessing uninitialised memory. the
values 4,5,9 appear in the first unittest and are left on the
stack. Unions ,unlike structs, do not initialise their fields
because it does not make sense to do so
On 06.01.2016 14:52, Nordlöw wrote:
At
https://github.com/D-Programming-Language/phobos/pull/3752
it would be nice if
return !haystack.empty && haystack.front.unaryFun!pred
was made nothrow.
Is this possible somehow?
try return !haystack.empty && pred(haystack.front);
catch
I have been converting C numeric libraries and depositing them
here: https://github.com/dataPulverizer. So far I have glpk and
nlopt converted on a like for like c function basics. I am now
stuck on the gsl library, primarily because of the preprocessor c
code which I am very new to. The
On Wednesday, 6 January 2016 at 15:41:27 UTC, Carl Sturtivant
wrote:
//D that doesn't work:
extern(C) int try(int x);
Try:
pragma(mangle, "try")
extern(C) int try_(int x);
then call it with the udnerscore in D, the linker should tie it
up thanks to the pragma.
On Wednesday, 6 January 2016 at 13:59:44 UTC, John Colvin wrote:
#define INLINE_FUN extern inline // used in gsl_pow_int.h:
INLINE_FUN double gsl_pow_2(const double x) { return x*x; }
Could I just ignore the INLINE_FUN and use alias for function
pointer declaration? For example ...
alias
On Wednesday, 6 January 2016 at 15:42:34 UTC, Adam D. Ruppe wrote:
On Wednesday, 6 January 2016 at 15:41:27 UTC, Carl Sturtivant
wrote:
//D that doesn't work:
extern(C) int try(int x);
Try:
pragma(mangle, "try")
extern(C) int try_(int x);
then call it with the udnerscore in D, the linker
Hello,
Is there a way from D to do this, without writing a C wrapper?
e.g. I want to call a C function named 'try'.
/* C prototype */
int try(int x);
//D that doesn't work:
extern(C) int try(int x);
Let's suppose that I want to implement a custom arithmetic type.
Looking through phobos at Complex, BigInt, HalfFloat, Variant,
etc, there is no consistent or idiomatic way to implement various
operators or functions on custom types.
1) Regarding unary operator overloading, what's the best
Hello,
From D I want to call e.g.
/* C++ prototype */
namespace ns {
int try(int x);
}
without writing a C or C++ wrapper.
Presumably the following D doesn't work, because it doesn't
mangle the name as if it's in the namespace ns.
pragma(mangle, "try") extern(C++, ns) int try_(int x);
On 01/06/2016 10:35 AM, Carl Sturtivant wrote:
Hello,
From D I want to call e.g.
/* C++ prototype */
namespace ns {
int try(int x);
}
without writing a C or C++ wrapper.
Presumably the following D doesn't work, because it doesn't mangle the
name as if it's in the namespace ns.
Why is init allowed to be redefined but not sizeof?
dmd 2.069
import std.stdio;
struct Foo {
static int init = 5;
static int sizeof = 0;
}
void main()
{
writeln(Foo.init);
writeln(Foo.sizeof);
}
Error: variable integer.Foo.sizeof .sizeof property cannot be redefined
On Wednesday, 06 January, 2016 04:01 PM, ric maicle wrote:
Why is init allowed to be redefined but not sizeof?
dmd 2.069
import std.stdio;
struct Foo {
static int init = 5;
static int sizeof = 0;
}
void main()
{
writeln(Foo.init);
writeln(Foo.sizeof);
}
Error: variable
Hello,
finally I want to learn how to do it right and I tried to
understand it from here
https://en.wikibooks.org/wiki/D_(The_Programming_Language)/d2/Modules
But I have a few questions. Do I have always to include std.stdio
in every file like in the example or is it enough just to import
On Wednesday, 6 January 2016 at 22:06:32 UTC, Namal wrote:
Do I have always to include std.stdio in every file like in the
example or is it enough just to import a module which has this
already included?
In every file that you use it, yes. Module imports are private to
the module (well,
On Wednesday, 6 January 2016 at 23:30:22 UTC, Guillaume Piolat
wrote:
Is there a fancy way to have some kind of string interpolation
in D?
Other than std.format.format that is?
On 06.01.2016 23:04, Jack Applegame wrote:
import std.algorithm;
struct Bar {
const int a;
int b;
}
void main() {
Bar[1] arr;
Bar bar = Bar(1, 2);
bar[0].b = 4;
Assuming you meant `arr[0].b = 4;`. Just overwriting the mutable part of
bar[0] is ok, of course.
import std.algorithm;
struct Bar {
const int a;
int b;
}
void main() {
Bar[1] arr;
Bar bar = Bar(1, 2);
bar[0].b = 4;
move(bar, arr[0]); // ok
arr[1] = bar;// fail, why?
move(Bar(1, 2), arr[0]); // fail, why source parameter isn't
auto ref?
}
Is there a fancy way to have some kind of string interpolation in
D?
On Wednesday, 6 January 2016 at 22:15:43 UTC, Adam D. Ruppe wrote:
You can import it as long as you define it!
I just tried to import one module with a main into another, but I
get this:
Error: only one main allowed
On Wednesday, 6 January 2016 at 21:58:51 UTC, Adam D. Ruppe wrote:
On Wednesday, 6 January 2016 at 21:50:23 UTC, Keywan Ghadami
wrote:
how to fix an SIGSEGV in invariant._d_invariant(Object)?
That means you are calling a method on a null object.
Your object might be at the bottom of the
On Wednesday, 6 January 2016 at 23:06:38 UTC, Adam D. Ruppe wrote:
On Wednesday, 6 January 2016 at 23:00:43 UTC, Namal wrote:
I just tried to import one module with a main into another,
but I get this:
You can't have two mains, but you can import a module with main
from another module
On Wednesday, 6 January 2016 at 23:30:22 UTC, Guillaume Piolat
wrote:
Is there a fancy way to have some kind of string interpolation
in D?
This is probably the best you're going to be able to do in D in
regards to string interpolation.
On Wednesday, 6 January 2016 at 23:12:27 UTC, Namal wrote:
On Wednesday, 6 January 2016 at 23:06:38 UTC, Adam D. Ruppe
wrote:
On Wednesday, 6 January 2016 at 23:00:43 UTC, Namal wrote:
I just tried to import one module with a main into another,
but I get this:
You can't have two mains, but
On Wednesday, 6 January 2016 at 21:50:23 UTC, Keywan Ghadami
wrote:
how to fix an SIGSEGV in invariant._d_invariant(Object)?
That means you are calling a method on a null object.
Your object might be at the bottom of the stack trace listing.
Check your code for a declared class that you
On Wednesday, 6 January 2016 at 23:00:43 UTC, Namal wrote:
I just tried to import one module with a main into another, but
I get this:
You can't have two mains, but you can import a module with main
from another module without one.
On Wednesday, 6 January 2016 at 14:17:51 UTC, anonymous wrote:
try return !haystack.empty && pred(haystack.front);
Might want to use std.exception.assumeWontThrow instead
return assumeWontThrow(!haystack.empty &&
pred(haystack.front));
On Wednesday, 6 January 2016 at 18:35:07 UTC, Carl Sturtivant
wrote:
Hello,
From D I want to call e.g.
/* C++ prototype */
namespace ns {
int try(int x);
}
without writing a C or C++ wrapper.
Presumably the following D doesn't work, because it doesn't
mangle the name as if it's in the
On 2016-01-06 19:35, Carl Sturtivant wrote:
Hello,
From D I want to call e.g.
/* C++ prototype */
namespace ns {
int try(int x);
}
without writing a C or C++ wrapper.
Presumably the following D doesn't work, because it doesn't mangle the
name as if it's in the namespace ns.
Huh, alright. Thanks.
Hi @all,
how to fix an SIGSEGV in invariant._d_invariant(Object)?
Maybe i should give some context:
I am learning D and started hacking the
dlangide(https://github.com/buggins/dlangide), and normally
finding the cause of an segmentation fault isn't that hard. But
this time it is somehow
35 matches
Mail list logo