On Monday, 14 April 2014 at 11:16:41 UTC, bearophile wrote:
John Colvin:
I think notInifnite is too contrived, you would always just
use `else` there. This is more realistic:
int notInfinite(in int b) pure nothrow {
if (b < 0)
return 10;
if (b > 10)
return 20;
// In re
I would like to iterate over T.tupleof at compiletime without having a
instance of the given type. So fare the only way I found that works is
the following
void iterateImpl(T, size_t i)()
{
static if(i < T.tupleof.length)
{
// do something with T.tupleof[i]
iterateImpl!(T, i+1)();
On Tuesday, 15 April 2014 at 08:18:31 UTC, Benjamin Thaut wrote:
I would like to iterate over T.tupleof at compiletime without
having a instance of the given type. So fare the only way I
found that works is the following
void iterateImpl(T, size_t i)()
{
static if(i < T.tupleof.length)
{
On Monday, 14 April 2014 at 15:16:07 UTC, bearophile wrote:
Steven Schveighoffer:
For that reason, I would disallow out parameters from casting
implicitly.
A number of things perplex me here.
1) If I attempt to compile foo2() more or less as presented with
2.065, the compiler tells me:
Er
Andrea Fontana:
What about:
static ~this() { "asdasdasd".writeln; }
I have added it.
Bye,
bearophile
On Tuesday, 15 April 2014 at 09:30:21 UTC, bearophile wrote:
Andrea Fontana:
What about:
static ~this() { "asdasdasd".writeln; }
I have added it.
Bye,
bearophile
http://dpaste.dzfl.pl/33cb0a05f0ff
Static destructor is called!
Application output:
spam at exit
bar at exit
foo at exit
Neve
Steve Teale:
1) If I attempt to compile foo2() more or less as presented
with 2.065, the compiler tells me:
Error: '_adDupT' is not nothrow
Error: function 'mu.foo2' is nothrow yet may throw
What version is the discussion about?
This rather fastidious limitation was finally removed in the
Andrea Fontana:
http://dpaste.dzfl.pl/33cb0a05f0ff
Static destructor is called!
Application output:
spam at exit
bar at exit
foo at exit
Never called
Well, we have a little mystery here :-) Using both the latest
beta of ldc2 and the latest alpha of dmd, on Windows32 I don't
see "Never call
On Tuesday, 15 April 2014 at 09:48:57 UTC, bearophile wrote:
Andrea Fontana:
http://dpaste.dzfl.pl/33cb0a05f0ff
Static destructor is called!
Application output:
spam at exit
bar at exit
foo at exit
Never called
Well, we have a little mystery here :-) Using both the latest
beta of ldc2 and
Andrea Fontana:
I think so. On dpaste using 2.063.2 or git version that
function isn't called. Only on 2.065..
The C exit() function is not required to honour D module
destructors.
More:
import std.stdio;
"Never called".writeln;
This doens't work on git version (only in 2.065). I think i
On Tuesday, 15 April 2014 at 08:18:31 UTC, Benjamin Thaut wrote:
void iterate(T)()
{
foreach(size_t i, m; T.tupleof)
// error message: "Need this to access "
{
// do something with m
}
}
Kind Regards
Benjamin Thaut
Is this acceptable?
void iterate(T)()
{
foreach (index,
T.init _is_ effectively an instance of given type here but it is
present in application anyway so it shouldn't create any _extra_
instance.
On Monday, 14 April 2014 at 10:30:53 UTC, Elvis Zhou wrote:
Running ./redis-pubsub-example
Callback subscribe(["test1"])
Task terminated with uncaught exception: expected of $ or *
The error message gives no hint of where the exception is
raised.How do you guys debug this type of error?
Foun
In general .stringof output is not defined by spec and is not
guaranteed to stay same between releases. This specific change
may be related to relatively recent consolidation of
const-evaluation to use CTFE consistently, I remember Don and
Kenji arguing on a very similar snippet.
On 04/15/14 12:45, Dicebot wrote:
> void iterate(T)()
> {
> foreach (index, member; T.init.tupleof)
> {
> pragma(msg, __traits(identifier, T.tupleof[index]));
> }
> }
>
> struct A
> {
> int a, b, c;
> }
>
> void main()
> {
> iterate!A();
> }
>
> Reason why you can't n
On 04/14/14 19:51, Andrej Mitrovic wrote:
> On Monday, 14 April 2014 at 17:48:31 UTC, Adam D. Ruppe wrote:
>> On Monday, 14 April 2014 at 17:45:52 UTC, Ryan Voots wrote:
>>> src/yage/core/misc.d(164): Error: e2ir: cannot cast this of type S to type
>>> void*
>>
>>
>> Try taking the address of this
On 4/15/14, Artur Skawina wrote:
> It *is* true. Classes are /reference types/, not references to classes.
I meant the part where he said you can't cast a reference to a pointer. You can.
On 4/15/14, Dicebot wrote:
> In general .stringof output is not defined by spec and is not
> guaranteed to stay same between releases.
The spec mentions this as well:
http://dlang.org/property.html#stringof
Quote:
-
Note: Using .stringof for code generation is not recommended, as the
intern
On Tuesday, 15 April 2014 at 11:25:14 UTC, Artur Skawina wrote:
void iterate(T)()
{
foreach (index, member; typeof(T.tupleof))
{
pragma(msg, __traits(identifier, T.tupleof[index]));
}
}
artur
So ashamed :D
On Tuesday, 15 April 2014 at 08:18:31 UTC, Benjamin Thaut wrote:
I would like to iterate over T.tupleof at compiletime without
having a instance of the given type.
*What* exactly are you trying to do? You could iterate over the
tupleof *types* instead if you want? Would that work for you?
fo
On 04/15/14 13:30, Andrej Mitrovic wrote:
> On 4/15/14, Artur Skawina wrote:
>> It *is* true. Classes are /reference types/, not references to classes.
>
> I meant the part where he said you can't cast a reference to a pointer. You
> can.
He obviously meant that you can't get a pointer to the o
On 04/15/14 13:33, Dicebot wrote:
> On Tuesday, 15 April 2014 at 11:25:14 UTC, Artur Skawina wrote:
>>void iterate(T)()
>>{
>>foreach (index, member; typeof(T.tupleof))
>>{
>>pragma(msg, __traits(identifier, T.tupleof[index]));
>>}
>>}
>
> So ashamed
On Tuesday, 15 April 2014 at 12:11:52 UTC, Artur Skawina wrote:
On 04/15/14 13:33, Dicebot wrote:
On Tuesday, 15 April 2014 at 11:25:14 UTC, Artur Skawina wrote:
void iterate(T)()
{
foreach (index, member; typeof(T.tupleof))
{
pragma(msg, __traits(identifier,
T.t
Am 15.04.2014 13:25, schrieb Artur Skawina:
On 04/15/14 12:45, Dicebot wrote:
void iterate(T)()
{
foreach (index, member; T.init.tupleof)
{
pragma(msg, __traits(identifier, T.tupleof[index]));
}
}
struct A
{
int a, b, c;
}
void main()
{
iterate!A();
}
Reason
On Tuesday, 15 April 2014 at 12:30:44 UTC, Benjamin Thaut wrote:
I want to iterate over the symbols, not over the types that the
symbols have. I need to iterate over the symbols, because UDAs
are attached to the symbols. Because of that none of the here
listed solutions work for me.
Here is a
Am 15.04.2014 14:33, schrieb Dicebot:
So, what is wrong with this?
void main(string[] args)
{
Bla bla;
foreach(index, a; typeof(Bla.tupleof))
{
pragma(msg, hasAttribute!(Bla.tupleof[index], Property).stringof);
}
}
http://dpaste.dzfl.pl/b38035362b29
Nothing, thanks for the s
On Tuesday, 15 April 2014 at 12:05:09 UTC, Artur Skawina wrote:
He obviously meant that you can't get a pointer to the object,
that the> reference points to, just by casting and w/o
address-of.
Yea, you can cast a class reference to void* (which does include
this inside a class), but not a ref
On 4/15/14, Artur Skawina wrote:
> He obviously meant that you can't get a pointer to the object, that the
> reference points to, just by casting and w/o address-of.
Ah right. I don't do this often so I forgot. The proper code would be:
int* f(ref int r) { return &r; }
There is another option. Using OpenDBX[0]. My binding here[1].
Its not exactly tested but since OpenDBX is a c library there
shouldn't be any issues as long as you can grab the appropriate
shared library version.
[0] http://www.linuxnetworks.de/doc/index.php/OpenDBX/Support
[1] https://github.c
Hello. For the past week or so I have been trying to get some
form of SDL with D. It seems that every tutorial I find is either
deprecated or incompatible with my system. Currently I am trying
to setup the SDL part of https://github.com/DerelictOrg. However
I cannot get it to run. I have follow
On Tuesday, 15 April 2014 at 14:21:45 UTC, Harpo wrote:
Hello. For the past week or so I have been trying to get some
form of SDL with D. It seems that every tutorial I find is
either deprecated or incompatible with my system. Currently I
am trying to setup the SDL part of
https://github.com/D
This is an useless post. Sometimes it's good to look at code in
other languages, and see their idioms, or to have an idea where
to go.
This is a simple problem, it just asks to simulate some rotations
of a Rubik's Cube:
http://www.reddit.com/r/dailyprogrammer/comments/22k8hu/492014_challenge
On Tuesday, 15 April 2014 at 10:53:42 UTC, Rikki Cattermole wrote:
On Monday, 14 April 2014 at 10:30:53 UTC, Elvis Zhou wrote:
Running ./redis-pubsub-example
Callback subscribe(["test1"])
Task terminated with uncaught exception: expected of $ or *
The error message gives no hint of where the e
On Tuesday, 15 April 2014 at 09:41:57 UTC, bearophile wrote:
Yes, foo2 is weakly pure, but main is not tagged as pure, so
main is free to use a global reference. If you mark main pure,
your code will not compile even if you comment out the writeln.
D is working as designed here.
3) Using a r
Steve Teale:
Since this is D-Learn, I can be indignant, and say that D needs
to get its act together, and have a clean definition of 'pure'.
What you describe is not only undocumented, but also far too
complicated - pure weak nothrow dontpiss kissmyass @never, and
so on if the direction conti
exten(C) {
testFunction(int function(int));
}
testFunction now requires an external function as parameter. It
can't be called with a pointer to a D function.
Logical Solution:
extern(C) {
testFunction(extern(D) int function(int)); // DOES NOT COMPILE
}
How do you fix this without mov
On Tuesday, 15 April 2014 at 20:15:42 UTC, Jeroen Bollen wrote:
exten(C) {
testFunction(int function(int));
}
testFunction now requires an external function as parameter. It
can't be called with a pointer to a D function.
Logical Solution:
extern(C) {
testFunction(extern(D) int funct
C has no knowledge of D ABI so this can't work. If you just want
to store D function pointer to later retrieve it and call from D
code, you can as well store it as void* (or extern(C) with
similar signature to preserve part of type) and cast upon
interfacing.
On Tuesday, 15 April 2014 at 20:19:36 UTC, Dicebot wrote:
C has no knowledge of D ABI so this can't work. If you just
want to store D function pointer to later retrieve it and call
from D code, you can as well store it as void* (or extern(C)
with similar signature to preserve part of type) and
Could somebody, please, give me some enlightening examples of
when it can be useful to have a enumerators with different types
such as in
enum {
A = 1.2f, // A is 1.2f of type float
B, // B is 2.2f of type float
int C = 3, // C is 3 of type int
D // D is 4 of type int
On 04/15/14 22:15, Jeroen Bollen wrote:
> exten(C) {
> testFunction(int function(int));
> }
>
> testFunction now requires an external function as parameter. It can't be
> called with a pointer to a D function.
>
> Logical Solution:
>
> extern(C) {
> testFunction(extern(D) int function(i
On Monday, 14 April 2014 at 16:13:38 UTC, FrankLike wrote:
I test move the DFL to x64,there are some things,who will help
me?
When I move the DFL to x64,then find some error:
internal\com.d(36):Error: cannot implicitly convert
expression)C_refCountInc(cast(void*)this)) of type ulong to uint
.
On Tuesday, 15 April 2014 at 22:40:50 UTC, FrankLike wrote:
On Monday, 14 April 2014 at 16:13:38 UTC, FrankLike wrote:
I test move the DFL to x64,there are some things,who will help
me?
When I move the DFL to x64,then find some error:
internal\com.d(36):Error: cannot implicitly convert
expres
On Tuesday, 15 April 2014 at 22:32:10 UTC, Artur Skawina wrote:
extern(C) {
extern (D) alias FP = int function(int);
void testFunction(FP);
}
artur
Still does not allow you to actually call it from C side, so this
is somewhat confusing.
I'd really just go with void*
On Tue, 15 Apr 2014 17:00:36 -0400, Nordlöw wrote:
Could somebody, please, give me some enlightening examples of when it
can be useful to have a enumerators with different types such as in
enum {
A = 1.2f, // A is 1.2f of type float
B, // B is 2.2f of type float
int C = 3,
On Tuesday, 15 April 2014 at 14:53:55 UTC, Elvis Zhou wrote:
The redis server is running, and another redis client example
but not this pubsub one works too.
Probably a bug then. Raise an issue on github please.
On Tuesday, 15 April 2014 at 18:02:00 UTC, bearophile wrote:
Steve Teale:
Since this is D-Learn, I can be indignant, and say that D
needs to get its act together, and have a clean definition of
'pure'. What you describe is not only undocumented, but also
far too complicated - pure weak nothro
47 matches
Mail list logo