On Sat, 07 Feb 2015 09:23:42 -0800, H. S. Teoh via Digitalmars-d-learn
wrote:
On Sat, Feb 07, 2015 at 02:35:13PM +, Danny via Digitalmars-d-learn
wrote:
[...]
cut- gdc
A.d cc1d: ../../src/gcc/d/dfrontend/statement.c:293:
On Sunday, 8 February 2015 at 09:52:50 UTC, Namespace wrote:
On Sunday, 8 February 2015 at 01:39:19 UTC, Gan wrote:
On Saturday, 7 February 2015 at 23:29:01 UTC, Namespace wrote:
On Saturday, 7 February 2015 at 22:09:03 UTC, Gan wrote:
Is there a better D graphics library in the works?
I'm
On Sat, 07 Feb 2015 21:33:46 +, Kenny wrote:
The above code snippet works correctly when I use LDC compiler (it finds
expected 'f' value and prints it to console). I'm wondering is it a bug
in DMD?
nope, this is a bug in your code. compiler (by the specs) is free to
perform intermediate
On 02/07/2015 06:35 AM, Danny wrote:
I'm trying to use immutable class instances and that seems to be really
difficult.
You are not alone. :)
Just some reminders:
- immutable is a requirement that may not be usable with every type.
- immutable string foo() {} is a member function that
nope, this is a bug in your code. compiler (by the specs) is
free to
perform intermediate calculations with any precision that is
not lower
than a highest used type (i.e. not lower that `float`'s one for
`while`
condition (`f + eps != f`). it may be even infinite precision,
so your
code may
On Sun, 08 Feb 2015 09:05:30 +, Kenny wrote:
Thanks, it's clear now. I still have one question in the above post, I
would appreciate if you check it too.
i've seen that, but i don't know the answer, sorry. here we have to
summon Walter to explain what his intentions was, how it should
For example, according to IEEE-754 specification if we work
with 32bit floating point numbers (floats in D) then the
following pseudo code prints 'Works'.
F32 f = 16777216.0f;
F32 f2 = f + 0.1f;
if is_the_same_binary_presentation(f, f2)
Print(Works);
As I understand D does not guarantee
On Sunday, 8 February 2015 at 09:19:08 UTC, Kenny wrote:
For example, according to IEEE-754 specification if we work
with 32bit floating point numbers (floats in D) then the
following pseudo code prints 'Works'.
F32 f = 16777216.0f;
F32 f2 = f + 0.1f;
if is_the_same_binary_presentation(f, f2)
i think you are mixing two things here. IEEE doesn't specify
which
internal representation compilers should use, it only specifies
the
results for chosen representation. so if D specs states that
`float`
calculations are always performing with `float` precision (and
specs
aren't), your sample
On 02/07/2015 06:35 AM, Danny wrote:
What I'm trying to do is save space by putting often-used Attrs into an
array and just compressing references to those into 1 Byte in the other
data structures where it's used (these other data structures are not
thread-local).
The following is based on
On Sunday, 8 February 2015 at 01:39:19 UTC, Gan wrote:
On Saturday, 7 February 2015 at 23:29:01 UTC, Namespace wrote:
On Saturday, 7 February 2015 at 22:09:03 UTC, Gan wrote:
Is there a better D graphics library in the works?
I'm using SFML(which is very easy and has lots of features)
but it
There is no right or wrong when you compare floating point
values for equality (and inequality) unless those values can be
represented exactly in the machine. 1.0 is famously not
representable exactly. (It is similar to how 1/3 cannot be
represented in the decimal system.)
Here I tested one
On Sunday, 8 February 2015 at 06:26:38 UTC, Ali Çehreli wrote:
On 02/07/2015 09:57 PM, Lave Zhang wrote:
Hi,
My first D program is like this:
---
import std.stdio;
void main(string[] args)
{
dstring s1 = hello你好d;
writeln(s1);
}
On Sun, 08 Feb 2015 09:19:06 +, Kenny wrote:
I asked more about this case:
float f = 16777216.0f;
if (f == f + 1.0f)
writeln(Works);
Although all operands are 32bit FP the result is not guaranteed to be
equal to the result for FP32 computations as specified by IEEE-754.
i think you
Also note that denormal numbers is an issue, e.g. D assumes that
they are always supported, I think. Which frequently is not the
case...
On 2015-02-08 at 06:36, Mike Parker wrote:
On 2/8/2015 11:32 AM, FG wrote:
On 2015-02-08 at 01:20, Mike Parker wrote:
In your case, forget destructors and the destroy method. Just
implement a common method on all of your objects that need cleanup
(perhaps name it 'terminate') and call that.
Hi Ketmar,
Hi Ali,
thank you!
On Sunday, 8 February 2015 at 09:42:14 UTC, Ali Çehreli wrote:
spawn(user, cucs, ubyte(3));
^to!
Other than that, it works.
(The Attributes are basically literal constants but the library
cannot know which are used in a given
On Sunday, 8 February 2015 at 16:28:21 UTC, fra wrote:
On Sunday, 8 February 2015 at 16:22:36 UTC, fra wrote:
Missclick... Anywya:
class Something
{
@disable this();
this(int i) {}
}
produces an undefined reference error.
I guess it has to do with classes implicitly inheriting from
I just realized that you cannot define a disabled default
constructor for classes: writing code like this will give a
linker error
class Something
{
On 2015-02-08 at 15:56, mzf wrote:
On Saturday, 7 February 2015 at 06:08:39 UTC, ketmar wrote:
On Sat, 07 Feb 2015 04:30:07 +, Safety0ff wrote:
False pointers, current GC is not precise.
not only that. constantly allocating big chunks of memory will inevitably
lead to OOM due to
On Sunday, 8 February 2015 at 16:22:36 UTC, fra wrote:
Missclick... Anywya:
class Something
{
@disable this();
this(int i) {}
}
produces an undefined reference error.
I guess it has to do with classes implicitly inheriting from
Object, and Object defining a this(), and @disable telling
fra:
However making it a compiler error would be far, far better
I think this can be filed in Bugzilla as diagnostic enhancement:
class Foo {
@disable this();
this(int i) {}
}
void main() {}
Bye,
bearophile
On Sunday, 8 February 2015 at 16:23:44 UTC, FG wrote:
2. auto buf = new byte[](1024*1024*100);
now the gc can't free this buf.
can i free it by manual?
Yes. import core.memory; GC.free(buf.ptr); // and don't use buf
afterwards
That won't work, see:
On 2015-02-08 at 19:15, safety0ff wrote:
On Sunday, 8 February 2015 at 16:23:44 UTC, FG wrote:
2. auto buf = new byte[](1024*1024*100);
now the gc can't free this buf.
can i free it by manual?
Yes. import core.memory; GC.free(buf.ptr); // and don't use buf afterwards
That
Thanks, my problem has been solved:)
---
import std.stdio;
import core.stdc.wchar_;
extern(C) int setlocale(int, char*);
static this()
{
fwide(core.stdc.stdio.stdout, 1);
setlocale(0, cast(char*)china);
}
int main(string[] args)
{
string s1 =
Let me hear what comes out. ;)
On Saturday, 7 February 2015 at 06:30:32 UTC, tcak wrote:
I have two char arrays at the size of 16KB. I will copy a part
of data between them again and again.
arrayA[0 .. dataLen] = arrayB[0 .. dataLen];
Does the compiler generate code that uses SIMD operations
(128-bits memory copy)
On Saturday, 7 February 2015 at 06:08:39 UTC, ketmar wrote:
On Sat, 07 Feb 2015 04:30:07 +, Safety0ff wrote:
False pointers, current GC is not precise.
not only that. constantly allocating big chunks of memory will
inevitably
lead to OOM due to current GC design. you can check it with
Hiho,
as I am currently very insterested in compiler implementation I
often look into the DMD github and look how things are done
there. Often I find myself curious about things at first but find
out the rational behind certain implementation decisions.
One thing I can't figure out is the
Hi, I couldn't find information about problem I'm having. This
builds:
enum { Option1, Option2 }
struct boring {
this(int Opt = Option1)(int arg1, int arg2) { ... }
}
However, I can't figure out how to instantiate that constructor.
When I call it like this:
auto a = boring(1, 2);
The
ChrisG:
I don't really understand how I'd differentiate a constructor
template from a class/struct template.
One solution is to use a template struct (struct/class names
start with an upper case in D, while typed enum members usually
start with a lower case):
enum E { option1, option2 }
On Sunday, 8 February 2015 at 18:43:18 UTC, FG wrote:
On 2015-02-08 at 19:15, safety0ff wrote:
That won't work, see:
http://forum.dlang.org/thread/uankmwjejsitmlmrb...@forum.dlang.org
Perhaps it was fixed in DMD 2.066.1, because this works for me
just fine:
Here's the link I couldn't
On Sunday, February 08, 2015 17:51:09 bearophile via Digitalmars-d-learn wrote:
fra:
However making it a compiler error would be far, far better
I think this can be filed in Bugzilla as diagnostic enhancement:
class Foo {
@disable this();
this(int i) {}
}
void main() {}
The
Thanks bearophile. Your first suggestion about making the struct
a template is something I considered. However, because of all the
code I've already written that approach would force me to use
inheritance or convert a ton of functions to templates. Ick.
The __ctor syntax looks like the answer
colors = [
black : నలుపు,
white : తెలుపు,
red : యెరుపు,
green : పచ్చ,
blue: నీలం
];
writefln(Before: );
writeln(colors);
colors = null;
class Outer
{
class Inner
{
static Inner createInner()
{
return new Inner(); //need 'this' to access member
this
}
}
}
Is this a bug?
If Inner is not nested, it works as expected:
class Inner
{
static Inner createInner()
{
Is there a simple way to parse a string as a char?
eg:
unittest{
assert(parseChar(`a`)=='a');
assert(parseChar(`\n`)=='\n'); //NOTE: I'm looking at `\n` not \n
// should also work with other forms of characters, see
http://dlang.org/lex.html
}
Note, std.conv.to doesn't work (`\n`.to!char
On Saturday, 7 February 2015 at 23:29:01 UTC, Namespace wrote:
On Saturday, 7 February 2015 at 22:09:03 UTC, Gan wrote:
Is there a better D graphics library in the works?
I'm using SFML(which is very easy and has lots of features)
but it seems to use a lot of ram(if you leave it running for a
Thank you for your reply. I didn't know that it isn't possible to
overload the post-inc and decrement operators in Dlang but I
think I don't even miss this feature if pre-inc/dec is still
available. =)
Tobias Pankrath:
Check for null with (x is null) not via printing to stdout.
In most cases instead of checking dynamic arrays for null, it's
better to use std.array.empty.
Bye,
bearophile
On 2/8/2015 4:09 PM, David Held wrote:
auto data = appender!(string[]);
...
data.put(someString);
[...]
Never mind. someString is actually the result of stdin.byLine(), which
returns a char[], not a string. I didn't notice this until just now.
.idup fixes this just fine
On 02/08/2015 01:05 PM, Robin wrote:
the postfix inc and decrement expressions are
inherited from BinExpr (binary expression) which define their second
expression to be an integer expression with a value of 1.
Post-increment cannot be overloaded in D. It is always implemented in
terms of
auto data = appender!(string[]);
...
data.put(someString);
source\colony.d(360): Error: template
std.array.Appender(string[]).Appender.put does not match any function
template declaration. Candidates are:
D:\D\dmd2\windows\bin\..\..\src\phobos\std\array.d(2251):
Never mind, stupid question I realize, would delete it if I could.
http://stackoverflow.com/questions/11047276/null-for-primitive-data-types
On 9/02/2015 3:40 p.m., Timothee Cour via Digitalmars-d-learn wrote:
Is there a simple way to parse a string as a char?
eg:
unittest{
assert(parseChar(`a`)=='a');
assert(parseChar(`\n`)=='\n'); //NOTE: I'm looking at `\n` not \n
// should also work with other forms of characters, see
On Sunday, 8 February 2015 at 23:13:33 UTC, Venkat Akkineni wrote:
Never mind, stupid question I realize, would delete it if I
could.
http://stackoverflow.com/questions/11047276/null-for-primitive-data-types
Check for null with (x is null) not via printing to stdout.
46 matches
Mail list logo