On 22-12-2011 23:51, Matej Nanut wrote:
Hello everyone, I've been fascinated by D lately and have been using it
for all
my school assignments (like simple ray casting and simulated annealing).
What I can't find anywhere is how to do something like
signal(SIGINT, myhandler) (I'm in a Linux
Hi guys!
I'm mostly familiar with C (and a bit of PHP). I've stumbled upon the D
language, and I must say I really like it.
Now I'm reading the The D Programming Language book, and I have a
couple of questions:
1. Uninitialized Arrays and GC.
Am 23.12.2011 16:25, schrieb Mr. Anonymous:
Hi guys!
I'm mostly familiar with C (and a bit of PHP). I've stumbled upon the D
language, and I must say I really like it.
Now I'm reading the The D Programming Language book, and I have a
couple of questions:
[]
3. const and immutable.
Is
On 23.12.2011 19:47, Ali Çehreli wrote:
On 12/23/2011 07:25 AM, Mr. Anonymous wrote:
I have a couple of questions:
I prefer separate threads for each. :)
Should I resend the questions as separate messages?
1. Uninitialized Arrays and GC.
Mr. Anonymous:
With the given example of: byte[1024] buffer = void;
So does the GC really scan this byte array?
The current D GC is not precise, so I think the current DMD+GC scan this array.
Future better compilers/runtimes probably will be able to avoid it (with a
shadow stack the gives
5. Align attribute.
http://dlang.org/attribute.html#align
struct S {
align(4) byte a; // placed at offset 0
align(4) byte b; // placed at offset 1
}
Explain this please.
align is a huge mess imo.
It matches the corresponding C compiler behavior
So what's the point of align in the first
On 23.12.2011 21:51, bearophile wrote:
Mr. Anonymous:
http://dlang.org/memory.html#uninitializedarrays
It's said here ^ that:
The uninitialized data that is on the stack will get scanned by the
garbage collector looking for any references to allocated memory.
With the given example of:
On 23.12.2011 19:47, Ali Çehreli wrote:
On 12/23/2011 07:25 AM, Mr. Anonymous wrote:
2. Setting Dynamic Array Length.
http://dlang.org/arrays.html#resize
A more practical approach would be to minimize the number of resizes
The solution works but is not as clean as just using array ~=
On 12/23/2011 11:51 AM, bearophile wrote:
Ali:
There is nothing in the language that makes me say the returned
object is unique; you can cast it to mutable or immutable freely.
The return value of strongly pure functions is implicitly castable to
immutable.
Is that working yet? The
On 12/23/2011 02:46 PM, Ali Çehreli wrote:
On 12/23/2011 12:36 PM, Mr. Anonymous wrote:
you generate an array of random numbers, and one of them appears to
be an address of an allocated array. This array won't free even if not
used anymore.
OK, I misread what you said. I thought you were
On Friday, December 23, 2011 09:47:35 Ali Çehreli wrote:
- To be more useful, function parameters should not insist on immutable
data, yet we type string all over the place.
That depends. If they're going to have to idup the data anyway, then it's
better to require that the argument be
On Friday, December 23, 2011 20:19:28 Mr. Anonymous wrote:
I saw that std.string functions use assumeUnique from std.exception.
As for your example, it probably should be:
char[] endWithDot(const(char)[] s)
{
return s.dup ~ '.';
}
No, that allocates _two_ strings - one from dup and
On Friday, December 23, 2011 14:51:06 bearophile wrote:
And sometimes inout helps.
Yeah, good point. I keep forgetting about inout, since it didn't work properly
before. So, the best way to implement Ali's function would be
inout(char)[] endWithDot(inout(char)[] s)
{
return s ~ '.';
}
-
On Friday, December 23, 2011 14:51:21 Ali Çehreli wrote:
On 12/23/2011 11:51 AM, bearophile wrote:
Ali:
There is nothing in the language that makes me say the returned
object is unique; you can cast it to mutable or immutable freely.
The return value of strongly pure functions is
Jonathan M Davis:
The feature is new, so it doesn't
yet work in all of the cases that it should, and it's not entirely clear
exactly far it will go. IIRC, Daniel Murphy and Steven were discussing it a
while back,
I have very recently opened another thread about it, but unfortunately it
On 12/23/2011 03:16 PM, Jonathan M Davis wrote:
On Friday, December 23, 2011 09:47:35 Ali Çehreli wrote:
- To be more useful, function parameters should not insist on immutable
data, yet we type string all over the place.
That depends. If they're going to have to idup the data anyway, then
The core problem for a number of these situations is how types are handled
with regards to expressions. In an expression such as
char[] arr = s ~ '.';
the type of the value being assigned is determined _before_ the assignment is
done. So, even though in theory the compiler could make it work,
17 matches
Mail list logo