Jonathan M Davis:
> Now, the confusing part is the fact that unlike C++, D allows you to put the
> const for making the function on the _left-hand_ side of the function (C++
> only lets you put it on the right). This is to increase consistency between
> modifers (public, override, pure, etc.) -
On Tue, Jan 24, 2012 at 07:06:47PM -0500, Jonathan M Davis wrote:
[...]
> So, while a C++ programmer expects that
>
> int f2() const
>
> means that f2 is const, they're likely to be surprised by the fact that in
>
> const int f1()
>
> it's the int that's const, not f1.
[...]
Wait, I thought 'c
Unfortunately you would have to do that with every template in order
to be consistent, and that's too much work. The real improvement would
be for the compiler to let us know *which* of the constraints failed,
e.g.:
alias KeyType!(int[]) Key;
Error: Can't instantiate KeyType!(int) due to failed c
On 01/24/2012 04:06 PM, Jonathan M Davis wrote:
>> class A {
>> int x;
>>
>> const int f1() { ... }
>> int f2() const { ... }
>> const(int) f3() { ... }
>> }
>>
[...]
> int f2() const
>
> becomes
>
> int f2(const A this)
>
> Now, the confusing part is the fact that unlike C++, D allows you to
On Fri, 20 Jan 2012 19:53:33 -0500, Matt Soucy wrote:
So I was messing around with some code I've been writing today, and I
wanted to use a foreach for something, as if it were an associative
array. The problem is, I can't find any information on how to do that.
I can't use something like "a
On 01/24/2012 10:28 PM, %u wrote:
Shouldn't this go into 'digitalmars.D' ?
It should go straight to the bug tracker.
On Tuesday, January 24, 2012 15:52:50 H. S. Teoh wrote:
> Hi all,
>
> I'm a bit confused by what 'const' means when used as part of a member
> function's signature:
>
> class A {
> int x;
>
> const int f1() { ... }
> int f2() const { ... }
> const(int) f3() { ... }
> }
>
> Is there a difference
Hi all,
I'm a bit confused by what 'const' means when used as part of a member
function's signature:
class A {
int x;
const int f1() { ... }
int f2() const { ... }
const(int) f3() { ... }
}
Is there a difference bet
Why not just go the "good old" way? you char* should be zero terminated
when coming from c.
private import core.stdc.stdlib,
std.stdio;
void main()
{
const(char)* str = "1234567890".ptr;
long lng = atoll(str);
writeln(lng);
}
On Tuesday, January 24, 2012 23:02:18 Mantis wrote:
> 24.01.2012 22:48, Mars пишет:
> > Hello everybody.
> > I have to convert a char* (from a C function) to long. At the moment
> > I'm using
> >
> >> long foo = to!long( to!string(bar) );
> >
> > but this doesn't feel right... with 2 to calls. Is
Shouldn't this go into 'digitalmars.D' ?
24.01.2012 22:48, Mars пишет:
Hello everybody.
I have to convert a char* (from a C function) to long. At the moment
I'm using
long foo = to!long( to!string(bar) );
but this doesn't feel right... with 2 to calls. Is this the way to go?
Or is there something better?
Mars
This seems to work:
Hello everybody.
I have to convert a char* (from a C function) to long. At the
moment I'm using
long foo = to!long( to!string(bar) );
but this doesn't feel right... with 2 to calls. Is this the way
to go? Or is there something better?
Mars
24.01.2012 20:49, bearophile пишет:
Mantis:
Of course, most likely that user already did type check, but if not,
this will give less cryptic error:
Error: static assert "Not associative array: int"
instantiated from here: KeyType!(int)
, instead of:
Error: template instance KeyType!(int) Key
On 01/24/2012 07:51 PM, xancorreu wrote:
Al 24/01/12 13:37, En/na Dejan Lekic ha escrit:
Xan, read this article please:
http://www.informit.com/articles/article.aspx?p=1609144
You have exactly what you are looking for in the D runtime and
standard library.
I read it and **after** I post the qu
Al 24/01/12 13:37, En/na Dejan Lekic ha escrit:
Xan, read this article please:
http://www.informit.com/articles/article.aspx?p=1609144
You have exactly what you are looking for in the D runtime and
standard library.
I read it and **after** I post the question. I don't know how
std.concurrency
Mantis:
> Of course, most likely that user already did type check, but if not,
> this will give less cryptic error:
>
> Error: static assert "Not associative array: int"
> instantiated from here: KeyType!(int)
>
> , instead of:
>
> Error: template instance KeyType!(int) KeyType!(int) does not
Am 24.01.2012 19:13, schrieb Caligo:
How did you compile it? As in my original post, it matters how you
compile it. In this case (I'm on a 64-bit GNU/Linux system),
compiling with '-inline' doesn't trigger the bug.
im on win7 (64bit) - but the windows dmd2.057 isn't able to produce x64
code
How did you compile it? As in my original post, it matters how you
compile it. In this case (I'm on a 64-bit GNU/Linux system),
compiling with '-inline' doesn't trigger the bug.
Am 24.01.2012 18:49, schrieb sclytrack:
dmd 2.057 give this result under windows/32bit
calculate1:
1.5
1.5
calculate2:
1.5
1.5
calculate3:
1.5
1.5
so its seems to be an x64 compiler bug
Yes, I missed my lessons in clear communication.
-
+
On Tue, Jan 24, 2012 at 6:51 AM, Dejan Lekic wrote:
> No, it is not a bug.
>
> Here is a hint:
>
> import std.stdio;
>
> int main() {
> float f;
> writeln(f);
> return 0;
> }
>
> /+--- output --+
> nan
> +--- end of output ---+/
>
wow, what a great hint.
sorry, but I'm not convinced
Yes, I missed my lessons in clear communication.
-
+ The complete source files.
-
import std.stdio;
void calculate1(float a, float b)
{
float s1 = 1.0f - a;
float s2 = a * b;
24.01.2012 8:43, Andrej Mitrovic пишет:
But I did implement them poorly, this is better:
import std.traits;
template KeyType(AA)
if (isAssociativeArray!AA)
{
static if (is(AA V : V[K], K))
{
alias K KeyType;
}
}
template ValueType(AA)
if (isAssociativeArray!AA
On Tuesday, January 24, 2012 15:53:48 C wrote:
> Hello all.
> After a quick recce on the main D site I couldn't find a how-to for large
> binary files.
>
> Suppose I'm using an old machine with limited memory, and I want to compute
> the MD5 hash of a 4 GB file.
> Do I need to buffer the input as
On Tue, 24 Jan 2012 15:53:48 +, C wrote:
> Hello all.
> After a quick recce on the main D site I couldn't find a how-to for
> large binary files.
>
> Suppose I'm using an old machine with limited memory, and I want to
> compute the MD5 hash of a 4 GB file.
> Do I need to buffer the input as i
double works correct under dmd64, but float not?
what is the behavior of dmd32 in this szenario?
can you give us a complete out-of-the-box compileable example (with
imports,main,etc.) with both examples the working/and nonworking
does it work correct with dmd(32bit)?
is this "calculate2" needed to reproduce the behavior?
and what compiler did you test: dmd64, (dmd32?), ...?
Am 24.01.2012
On Tuesday, January 24, 2012 14:03:01 Gour wrote:
> On Tue, 24 Jan 2012 13:41:31 +0100
>
> "Dejan Lekic" wrote:
> > Many things changed since the book has been released. I is
> > strange that you did not see the link to the TDLP errata
> > (http://erdani.com/tdpl/errata/) by now. :)
>
> I saw er
Hello all.
After a quick recce on the main D site I couldn't find a how-to for large
binary files.
Suppose I'm using an old machine with limited memory, and I want to compute
the MD5 hash of a 4 GB file.
Do I need to buffer the input as in C++? And how should I check for exceptions?
Example code m
On 01/24/2012 04:41 PM, sclytrack wrote:
On 01/24/2012 01:51 PM, Dejan Lekic wrote:
No, it is not a bug.
Here is a hint:
import std.stdio;
int main() {
float f;
writeln(f);
return 0;
}
/+--- output --+
nan
+--- end of output ---+/
I don't understand.
I see now I forgot the input
On 01/24/2012 01:51 PM, Dejan Lekic wrote:
No, it is not a bug.
Here is a hint:
import std.stdio;
int main() {
float f;
writeln(f);
return 0;
}
/+--- output --+
nan
+--- end of output ---+/
I don't understand.
void calculate2(float a, float b)
{
float s1 = 1.0 - a;
float s2 = a * b;
writeln(s2);
writeln(a * b);
}
Output:
t*b= 0
t*b= 1.5
assume CS:.text._D4main10calculate2FffZv
_D4main10calculate2FffZv:
push
How about something like this (using Juno):
///
import juno.com.core, std.stdio;
abstract final class SystemInformation {
mixin(uuid("C01B9BA0-BEA7-41BA-B604-D0A36F469133"));
mixin Interfaces!(ISystemInformation);
}
interface ISystemInformation : IDispatch
{
mixin(uuid(
On Tue, 24 Jan 2012 13:41:31 +0100
"Dejan Lekic" wrote:
> Many things changed since the book has been released. I is
> strange that you did not see the link to the TDLP errata
> (http://erdani.com/tdpl/errata/) by now. :)
I saw errata, but one does not expect to consult book's errata for the
c
I've never used the Windows update API, but isn't it a COM interface rather
than a
C++ interface? You can call those directly from D.
Andrej, I agree, they should be in std.traits .
No, it is not a bug.
Here is a hint:
import std.stdio;
int main() {
float f;
writeln(f);
return 0;
}
/+--- output --+
nan
+--- end of output ---+/
On Tuesday, 24 January 2012 at 12:30:26 UTC, David Eagen wrote:
I'm trying to understand how to call a C++ library from D.
Specifically,
the Windows Update API.
My goal is rather simple in that I want to detect whether there
is a
reboot pending for the system. To do that I need to call the
IS
Unfortunately, you cant use C++ namespaces. More about
interfacing to C++ here: http://www.dlang.org/cpp_interface.html .
The easiest way to solve this is to write a C function that will
glue your code with the C++ library.
Many things changed since the book has been released. I is
strange that you did not see the link to the TDLP errata
(http://erdani.com/tdpl/errata/) by now. :)
Xan, read this article please:
http://www.informit.com/articles/article.aspx?p=1609144
You have exactly what you are looking for in the D runtime and
standard library.
I'm trying to understand how to call a C++ library from D. Specifically,
the Windows Update API.
My goal is rather simple in that I want to detect whether there is a
reboot pending for the system. To do that I need to call the
ISystemInformation::RebootRequired property but I don't know how to do
On 2012-01-24 09:43, Robert Lumley wrote:
hi all :) i'm new to D and i'm trying to get step to compile on the Mac.
below is the template that gives the error:
dstep/internal/Reflection.d:205:0 expression "objcObject_"c ==
cast(char[])field is not constant or does not evaluate to a bool
private
On 2012-01-24 13:26, Jacob Carlborg wrote:
On 2012-01-24 09:43, Robert Lumley wrote:
hi all :) i'm new to D and i'm trying to get step to compile on the Mac.
below is the template that gives the error:
dstep/internal/Reflection.d:205:0 expression "objcObject_"c ==
cast(char[])field is not const
---
alias float Real;
Real lerp(Real t, Real a, Real b)
{
Real s2 = t * b;
writeln("t*b= ", s2);
writeln("t*b= ", t * b);
return s2;
}
Output:
t*b= 1.5
t*b= 1.5
-
alias float Real;
Real lerp(Real t,
t=0.75, a=-2.00, b=2.00, s1=-0.50, s2=0.00,
rt1=-0.50, rt2=1.50 :::
1.5
t = 0.75ok
a = -2.0ok
b = 2.0 ok
s1 = -0.5 ok
s2 = 1.5 //
Something like
Class MyActor : Actor {
receive {
case i int: writeln("Received integer: ", i)
}
}
pseudocode
2012/1/23 Timon Gehr :
> On 01/23/2012 08:01 PM, Xan xan wrote:
>>
>> Hi.
>>
>> Is there any actors library in D. Spawn and etc is ok, but I want more
>> high-level thing and acto
On 01/24/2012 04:13 AM, Caligo wrote:
alias double Real;
//alias float Real;
// simple linear interpolation; I partitioned the internals to help me
figure out what was happening.
Real lerp(Real t, Real a, Real b){
Real s1 = (1.0 - t) * a;
Real s2 = t * b;
Real rt1 = s1 + s2;
Real rt2
I own TDPL. The discrepancies are few and far between.
hi all :) i'm new to D and i'm trying to get step to compile on
the Mac. below is the template that gives the error:
dstep/internal/Reflection.d:205:0 expression "objcObject_"c ==
cast(char[])field is not constant or does not evaluate to a bool
private template hasFieldImpl (T, string field
50 matches
Mail list logo