On 04/13/2012 09:00 PM, F i L wrote:
default is NaN
Just to complete the picture, character types have invalid initial
values as well: 0xFF, 0x, and 0x for char, wchar, and dchar,
respectively.
Ali
On Friday, April 13, 2012 23:29:40 Ali Çehreli wrote:
On 04/13/2012 09:00 PM, F i L wrote:
default is NaN
Just to complete the picture, character types have invalid initial
values as well: 0xFF, 0x, and 0x for char, wchar, and dchar,
respectively.
Yeah. Thanks for mentioning
F i L wrote:
It sounds like circular reasoning.
Several considerations pressed the design into the current form:
1) always changing output on unchanged input is hard to debug
2) GC needs to be saved from garbage, that looks like pointers
3) missed explicit initializations should not create
Jonathan M Davis wrote:
No. You always have a bug if you don't initialize a variable to
the value that
it's supposed to be. It doesn't matter whether it's 0, NaN,
527.1209823, or
whatever. All having a default value that you're more likely to
use means is
that you're less likely to have to
On Saturday, 14 April 2012 at 06:43:11 UTC, Manfred Nowak wrote:
F i L wrote:
It sounds like circular reasoning.
Several considerations pressed the design into the current form:
1) always changing output on unchanged input is hard to debug
2) GC needs to be saved from garbage, that looks
On Saturday, 14 April 2012 at 06:29:40 UTC, Ali Çehreli wrote:
On 04/13/2012 09:00 PM, F i L wrote:
default is NaN
Just to complete the picture, character types have invalid
initial values as well: 0xFF, 0x, and 0x for char,
wchar, and dchar, respectively.
Ali
That's
On Saturday, April 14, 2012 09:58:42 F i L wrote:
On Saturday, 14 April 2012 at 06:29:40 UTC, Ali Çehreli wrote:
On 04/13/2012 09:00 PM, F i L wrote:
default is NaN
Just to complete the picture, character types have invalid
initial values as well: 0xFF, 0x, and 0x for
On Saturday, 14 April 2012 at 07:59:25 UTC, Jonathan M Davis
wrote:
On Saturday, April 14, 2012 09:45:57 F i L wrote:
If D doesn't accommodate entering Laymen, how does it expect to
gain popularity in any major way? Efficiency puts D on the map,
convenience is what brings the tourists.
I
On Saturday, 14 April 2012 at 07:52:51 UTC, F i L wrote:
On Saturday, 14 April 2012 at 06:43:11 UTC, Manfred Nowak wrote:
F i L wrote:
4) use hardware signalling to overcome some of the limitations
impressed by 3).
4) I have no idea what you just said... :)
On Saturday, 14 April 2012 at
Am 14.04.2012 07:48, schrieb F i L:
On Saturday, 14 April 2012 at 05:19:38 UTC, dennis luehring wrote:
Am 14.04.2012 06:00, schrieb F i L:
struct Foo {
int x, y;// ready for use.
float z, w; // messes things up.
float r = 0; // almost always...
}
What is the status of shared types ?
I try it with gdmd v4.6.3
And I not get any warring/error when I do anything over a shared variable
without using atomicOp. It's normal ?
shared ushort ram[ram_size];
ram[i] = cast(ushort) (bytes[0] | bytes[1] 8);
--
I'm afraid that I have a
On 14/04/12 09:45, F i L wrote:
Jonathan M Davis wrote:
No. You always have a bug if you don't initialize a variable to the value that
it's supposed to be. It doesn't matter whether it's 0, NaN, 527.1209823, or
whatever. All having a default value that you're more likely to use means is
that
F i L:
So basically, it's for debugging?
To avoid bugs it's useful for all variables to be initialized
before use (maybe with an explicit annotation for the uncommon
cases where you want to use uninitialized memory, like:
http://research.swtch.com/sparse ). Having a variable not
On 4/14/12, bearophile bearophileh...@lycos.com wrote:
Having a variable not initialized is a common source of bugs.
I'm going to argue that this was true for C/C++ but is much less true
for D. One benefit of having integrals initialized to 0 is that you
now have a defined default that you can
Jerome BENOIT wrote:
Why would a compiler set `real' to 0.0 rather then 1.0, Pi,
?
Because 0.0 is the lowest (smallest, starting point, etc..)
numerical value. Pi is the corner case and obviously has to be
explicitly set.
If you want to take this further, chars could even be
On Saturday, 14 April 2012 at 10:38:45 UTC, Silveri wrote:
On Saturday, 14 April 2012 at 07:52:51 UTC, F i L wrote:
On Saturday, 14 April 2012 at 06:43:11 UTC, Manfred Nowak
wrote:
F i L wrote:
4) use hardware signalling to overcome some of the limitations
impressed by 3).
4) I have no idea
dennis luehring wrote:
what does make float default to 0.0 better - does it just feel
better?
Not just. It's consistent with Int types, therefor easier for
newbs to pick up since all numeric value types behave the same.
I even think char should default to a usable value as well. Most
On Saturday, 14 April 2012 at 12:48:01 UTC, Andrej Mitrovic wrote:
On 4/14/12, bearophile bearophileh...@lycos.com wrote:
Having a variable not initialized is a common source of bugs.
I'm going to argue that this was true for C/C++ but is much
less true
for D. One benefit of having integrals
On 4/14/12, F i L witte2...@gmail.com wrote:
This is exactly what I'm trying to get at.
Anyway it's not all bad news since we can use a workaround:
struct Float {
float payload = 0.0;
alias payload this;
}
void main() {
Float x; // acts as a float, is initialized to 0.0
}
Not
On 14/04/12 16:47, F i L wrote:
Jerome BENOIT wrote:
Why would a compiler set `real' to 0.0 rather then 1.0, Pi, ?
Because 0.0 is the lowest (smallest, starting point, etc..)
quid -infinity ?
numerical value. Pi is the corner case and obviously has to be explicitly set.
If you
On Saturday, 14 April 2012 at 15:44:46 UTC, Jerome BENOIT wrote:
On 14/04/12 16:47, F i L wrote:
Jerome BENOIT wrote:
Why would a compiler set `real' to 0.0 rather then 1.0, Pi,
?
Because 0.0 is the lowest (smallest, starting point, etc..)
quid -infinity ?
The concept of zero is
On Saturday, 14 April 2012 at 15:35:13 UTC, Andrej Mitrovic wrote:
On 4/14/12, F i L witte2...@gmail.com wrote:
This is exactly what I'm trying to get at.
Anyway it's not all bad news since we can use a workaround:
struct Float {
float payload = 0.0;
alias payload this;
}
void
On 4/14/12, F i L witte2...@gmail.com wrote:
a Hack though, since it doesn't work with 'auto'.
What do you mean?
On Saturday, 14 April 2012 at 17:30:19 UTC, Andrej Mitrovic wrote:
On 4/14/12, F i L witte2...@gmail.com wrote:
a Hack though, since it doesn't work with 'auto'.
What do you mean?
Only that:
auto f = 1.0f; // is float not Float
On 4/14/12, F i L witte2...@gmail.com wrote:
auto f = 1.0f; // is float not Float
UFCS in 2.059 to the rescue:
struct Float
{
float payload = 0.0;
alias payload this;
}
@property Float f(float val) { return Float(val); }
void main()
{
auto f = 1.0.f;
}
On 14/04/12 18:38, F i L wrote:
On Saturday, 14 April 2012 at 15:44:46 UTC, Jerome BENOIT wrote:
On 14/04/12 16:47, F i L wrote:
Jerome BENOIT wrote:
Why would a compiler set `real' to 0.0 rather then 1.0, Pi, ?
Because 0.0 is the lowest (smallest, starting point, etc..)
quid
On Saturday, 14 April 2012 at 18:02:57 UTC, Andrej Mitrovic wrote:
On 4/14/12, F i L witte2...@gmail.com wrote:
auto f = 1.0f; // is float not Float
UFCS in 2.059 to the rescue:
struct Float
{
float payload = 0.0;
alias payload this;
}
@property Float f(float val) { return
I have following code:
import std.array, std.range, std.stdio;
struct CommonInputRange(E)
{
@property bool delegate() empty;
@property E delegate() front;
void delegate() popFront;
}
void main(string[] args)
{
alias CommonInputRange!dchar DCRange;
static
On Saturday, 14 April 2012 at 18:07:41 UTC, Jerome BENOIT wrote:
On 14/04/12 18:38, F i L wrote:
On Saturday, 14 April 2012 at 15:44:46 UTC, Jerome BENOIT
wrote:
On 14/04/12 16:47, F i L wrote:
Jerome BENOIT wrote:
Why would a compiler set `real' to 0.0 rather then 1.0, Pi,
?
Because
On 4/14/12, Jerome BENOIT g62993...@rezozer.net wrote:
I would even say that D may go further by setting a kind of NaN for integers.
That's never going to happen.
F i L wrote:
You can't force new D programmers to follow a 'guidline'
By exposing a syntax error for every missed explicit initialization the
current guideline would be changed into an insurmountable barrier,
forcing every new D programmers to follow the 'guidline'.
-manfred
I have this simple binary arithmetic coder in C++ by Mahoney and
translated to D by Maffi. I added notrow, final and pure
and GC.disable where it was possible, but that didn't made much
difference. Adding const to the Predictor.p() (as in the C++
version) gave 3% higher performance. Here the
Hi,
I try to translate a script I wrote in Fantom [www.fantom.org].
In my script, I have a type Tag defined as a triple of:
- String (the name of the tag),
- Type (the type of the tag: could be Str, Date, Int, etc.)
- Obj (the value of the tag; Fantom has Objects of Top-Class
hierachy).
On 14/04/12 16:52, F i L wrote:
The initialization values chosen are also determined by the underlying
hardware implementation of the type. Signalling NANs
(http://en.wikipedia.org/wiki/NaN#Signaling_NaN) can be used with floats
because they are implemented by the CPU, but in the case of
On 14/04/12 20:51, F i L wrote:
On Saturday, 14 April 2012 at 18:07:41 UTC, Jerome BENOIT wrote:
On 14/04/12 18:38, F i L wrote:
On Saturday, 14 April 2012 at 15:44:46 UTC, Jerome BENOIT wrote:
On 14/04/12 16:47, F i L wrote:
Jerome BENOIT wrote:
Why would a compiler set `real' to 0.0
On 14/04/12 21:05, ReneSac wrote:
Lang| Comp | Binary size | Time (lower is better)
C++ (g++) - 13kb - 2.42s (100%) -O3 -s
D (DMD) - 230kb - 4.46s (184%) -O -release -inline
D (GDC) - 1322kb - 3.69s (152%) -O3 -frelease -s
Try using extra optimizations for GDC. Actually, GDC has a dmd-like
On Saturday, 14 April 2012 at 19:05:40 UTC, ReneSac wrote:
I have this simple binary arithmetic coder in C++ by Mahoney
and translated to D by Maffi. I added notrow, final and
pure and GC.disable where it was possible, but that didn't
made much difference. Adding const to the Predictor.p()
I thought the following would terminate gracefully having printed 0..9
in some (random) order:
#! /usr/bin/env rdmd
import std.algorithm ;
import std.range ;
import std.stdio ;
import core.thread ;
int main ( immutable string[]
Forgot to mention specs: Dualcore Athlon II X2 240 (2.8GHz), 4GB
RAM, FreeBSD 9 x64, both compilers are 64bit.
On 04/14/12 20:47, Piotr Szturmaj wrote:
I have following code:
import std.array, std.range, std.stdio;
struct CommonInputRange(E)
{
@property bool delegate() empty;
@property E delegate() front;
void delegate() popFront;
}
void main(string[] args)
{
alias
On Saturday, 14 April 2012 at 19:40:06 UTC, Aleksandar Ružičić
wrote:
On Saturday, 14 April 2012 at 19:17:52 UTC, Xan wrote:
Hi,
I try to translate a script I wrote in Fantom
[www.fantom.org]. In my script, I have a type Tag defined as
a triple of:
- String (the name of the tag),
- Type
On 14-04-2012 18:04, Russel Winder wrote:
I thought the following would terminate gracefully having printed 0..9
in some (random) order:
#! /usr/bin/env rdmd
import std.algorithm ;
import std.range ;
import std.stdio ;
import core.thread ;
Le 14/04/2012 21:53, q66 a écrit :
On Saturday, 14 April 2012 at 19:05:40 UTC, ReneSac wrote:
I have this simple binary arithmetic coder in C++ by Mahoney and
translated to D by Maffi. I added notrow, final and pure and
GC.disable where it was possible, but that didn't made much
difference.
On Saturday, 14 April 2012 at 20:58:01 UTC, Somedude wrote:
Le 14/04/2012 21:53, q66 a écrit :
On Saturday, 14 April 2012 at 19:05:40 UTC, ReneSac wrote:
I have this simple binary arithmetic coder in C++ by Mahoney
and
translated to D by Maffi. I added notrow, final and
pure and
GC.disable
On 04/14/2012 04:56 PM, Alex Rønne Petersen wrote:
On 14-04-2012 18:04, Russel Winder wrote:
I thought the following would terminate gracefully having printed 0..9
in some (random) order:
#! /usr/bin/env rdmd
import std.algorithm ;
import std.range ;
import std.stdio ;
import core.thread ;
On 04/14/12 18:04, Russel Winder wrote:
I thought the following would terminate gracefully having printed 0..9
in some (random) order:
#! /usr/bin/env rdmd
import std.algorithm ;
import std.range ;
import std.stdio ;
import core.thread ;
Le 14/04/2012 18:04, Russel Winder a écrit :
I thought the following would terminate gracefully having printed 0..9
in some (random) order:
#! /usr/bin/env rdmd
import std.algorithm ;
import std.range ;
import std.stdio ;
import
On Saturday, April 14, 2012 20:47:20 Piotr Szturmaj wrote:
I have following code:
import std.array, std.range, std.stdio;
struct CommonInputRange(E)
{
@property bool delegate() empty;
@property E delegate() front;
void delegate() popFront;
}
void main(string[] args)
I tested the q66 version in my computer (sandy bridge @ 4.3GHz).
Repeating the old timmings here, and the new results are marked
as D-v2:
test.fpaq0 (16562521 bytes) - test.bmp (33159254 bytes)
Lang| Comp | Binary size | Time (lower is better)
C++ (g++) - 13kb - 2.42s (100%) -O3
On Sunday, April 15, 2012 03:51:59 ReneSac wrote:
About compiler optimizations, -finline-functions and -fweb are
part of -O3. I tried to compile with -no-bounds-check, but made
no diference for DMD and GDC. It probably is part of -release as
q66 said.
Not quite. -noboundscheck turns off _all_
On 14/04/12 23:03, q66 wrote:
He also uses a class. And -noboundscheck should be automatically induced by
-release.
Ahh, THAT probably explains why some of my numerical code is so markedly
different in speed when compiled using DMD with or without the -release switch.
It's a MAJOR
On 14/04/12 23:03, q66 wrote:
He also uses a class. And -noboundscheck should be automatically induced by
-release.
... but the methods are marked as final -- shouldn't that substantially reduce
any speed hit from using class instead of struct?
On Sunday, April 15, 2012 04:21:09 Joseph Rushton Wakeling wrote:
On 14/04/12 23:03, q66 wrote:
He also uses a class. And -noboundscheck should be automatically induced
by
-release.
... but the methods are marked as final -- shouldn't that substantially
reduce any speed hit from using
On Saturday, April 14, 2012 19:31:40 Jonathan M Davis wrote:
On Sunday, April 15, 2012 04:21:09 Joseph Rushton Wakeling wrote:
On 14/04/12 23:03, q66 wrote:
He also uses a class. And -noboundscheck should be automatically induced
by
-release.
... but the methods are marked as
On Sunday, 15 April 2012 at 02:20:34 UTC, Joseph Rushton Wakeling
wrote:
On 14/04/12 23:03, q66 wrote:
He also uses a class. And -noboundscheck should be
automatically induced by
-release.
Ahh, THAT probably explains why some of my numerical code is so
markedly different in speed when
On 15/04/12 04:37, jerro wrote:
I know this isn't what your post was about, but you really should compile
numerical code with GDC instead of DMD if you care about performance. It
generates much faster floating point code.
It's exactly what I do. :-)
On Saturday, 14 April 2012 at 19:51:21 UTC, Joseph Rushton Wakeling wrote:
GDC has all the regular gcc optimization flags available IIRC. The ones on the
GDC man page are just the ones specific to GDC.
I'm not talking about compiler flags, but the inline keyword in the C++ source
code. I saw
(I have a memory of a program that took
~0.004s with a C/C++ version and 1s with D, and the difference
seemed to be just startup time for the D program.)
I have never seen anything like that. Usually the minimal time to
run a D program is something like:
j@debian:~$ time ./hello
Hello
On Sunday, 15 April 2012 at 03:41:55 UTC, jerro wrote:
(I have a memory of a program that took
~0.004s with a C/C++ version and 1s with D, and the difference
seemed to be just startup time for the D program.)
I have never seen anything like that. Usually the minimal time
to run a D program
On 15/04/12 05:41, jerro wrote:
I have never seen anything like that. Usually the minimal time to run a D
program is something like:
j@debian:~$ time ./hello
Hello world!
real 0m0.001s
user 0m0.000s
sys 0m0.000s
Yea, my experience too in general. I can't remember exactly what I was testing
60 matches
Mail list logo