Is it possible to temporarily prevent the garbage collector from
collecting a memory block even if there are no references to it?
The use case is as follows: I want to call a C library function
which expects to take ownership of a buffer. It looks something
like this:
alias FreeFunc =
On Thursday, 24 April 2014 at 20:09:38 UTC, Justin Whear wrote:
You can use GC.addRoot() from core.memory before passing the
pointer to
the C function, then use GC.removeRoot in your myFree function.
Perfect, thanks!
Say I have two structs, defined like this:
struct A { /* could contain whatever */ }
struct B { A a; }
My question is, is it now guaranteed that A.sizeof==B.sizeof,
regardless of how A is defined (member variable types, alignment,
etc.)? More to the point, say I have a function
On Saturday, 19 April 2014 at 12:26:16 UTC, Andrej Mitrovic via
Digitalmars-d-learn wrote:
On 4/19/14, Lars T. Kyllingstad via Digitalmars-d-learn
digitalmars-d-learn@puremagic.com wrote:
Say I have two structs, defined like this:
struct A { /* could contain whatever */ }
struct B
On Mon, 27 Jun 2011 16:41:14 -0400, bearophile wrote:
This question is related to this thread:
http://d.puremagic.com/issues/show_bug.cgi?id=3632
Can you tell me why real.nan and real.init don't contain the same bit
patterns?
import std.math: isIdentical;
void main() {
On Wed, 15 Jun 2011 23:57:25 +, Justin Whear wrote:
Consider the following:
You have 10 million data points and you need to apply a multipass
algorithm to them. Each pass is like a cellular automata: it can read
from the previous pass but it doesn't know the current values. This
makes
On Thu, 16 Jun 2011 06:52:45 -0400, Michel Fortin wrote:
On 2011-06-15 23:29:46 -0400, Charles McAnany mcana...@rose-hulman.edu
said:
Ah, so does the compiler figure out which ones are strongly and weakly
pure and then optimize as
appropriate? Is there a way to indicate that a function is
On Thu, 16 Jun 2011 17:38:27 +, Charles McAnany wrote:
Ok, I think I get it. That cleared it up. =). So, if you have a
functioned labelled pure, it's your job to not pass it mutable
arguments, but the compiler's job to make sure it doesn't mutate
anything not in the arguments. And that's
On Mon, 09 May 2011 09:49:04 +0100, Russel Winder wrote:
On Sun, 2011-05-08 at 23:52 -0700, Jonathan M Davis wrote: [ . . . ]
I could look at writing an article on moving from std.date to
std.datetime, I suppose. We already have an article contest going, and
it would make sense to put such an
On Sat, 30 Apr 2011 00:09:09 -0400, Andrej Mitrovic wrote:
import std.range;
void main()
{
int[] a = [1, 2, 3];
a.put(6);
assert(a == [2, 3]);
a.put([1, 2]);
assert(a.length == 0);
}
Seems kind of odd.. put is implemented as an append method for some
On Wed, 16 Mar 2011 11:20:43 +0100, spir wrote:
On 03/16/2011 06:41 AM, Jesse Phillips wrote:
Ali Çehreli Wrote:
Right? Is there a better way that I am missing?
Thank you,
Ali
No better way, the stated reason IIRC is that it is easier to remove
the new line then to append it back on.
On Sat, 05 Mar 2011 18:12:30 +, Lars T. Kyllingstad wrote:
On Sat, 05 Mar 2011 10:15:48 -0700, user wrote:
On 03/04/2011 09:22 PM, Jonathan M Davis wrote:
On Friday 04 March 2011 20:14:32 Kai Meyer wrote:
I have an 'enforce' function call in an 'in' block for a function.
When I compile
On Wed, 02 Mar 2011 13:35:11 +0100, Magnus Lie Hetland wrote:
First question: I just noticed that writefln(%a, 1.2) writes
0x1.3p+0, while writeln(format(%a, 1.2)) (that is, with
std.string.format) writes 0x9.8p-3 ... wouldn't it be nice
to be consistent here? (The
On Sun, 27 Feb 2011 15:52:01 +0100, simendsjo wrote:
I'm having some problems grokking version.
How would I translate this simple C macro? #if !defined(IDENT) ||
!defined(IDENT2)
I've tried the following:
version(!IDENT)
identifier or integer expected, not !
!version(IDENT)
On Thu, 24 Feb 2011 13:27:39 -0500, Trass3r wrote:
Why doesn't this work:
import std.stdio;
void main()
{
float a,b=0;
writefln(%x %x, a, b);
}
std.format.FormatError: std.format floating
That is because %x is for formatting integers. If you want a hex
representation of
The dmd help text says the following about the -nofloat switch:
-nofloat do not emit reference to floating point
What does this mean? What is -nofloat good for?
-Lars
On Sun, 20 Feb 2011 15:23:29 -0500, Steven Schveighoffer wrote:
On Sun, 20 Feb 2011 14:51:10 -0500, bearophile
bearophileh...@lycos.com wrote:
Jacob Carlborg:
Every time I try to use D2 it's just a PITA to use. I've used D1 and
Tango for
several years and had no problem with that.
I
On Mon, 21 Feb 2011 12:18:54 +0100, Magnus Lie Hetland wrote:
On 2011-02-20 19:22:20 +0100, Magnus Lie Hetland said:
On 2011-02-19 22:25:31 +0100, Nick Sabalausky said:
[snip]
Unfortunately, rdmd doesn't seem to have gotten much attention lately.
I've had a few patches for it sitting in
On Fri, 18 Feb 2011 02:02:51 +, Sean Eskapp wrote:
If I have
class Bar(T)
{
}
void foo(Y)()
{
...
}
Is there a way to check inside foo() that Y is in some way an
instantiation of Bar? Is there a way to find WHICH instantiation it is?
void foo(Y)()
{
static if (is(Y Z
On Fri, 18 Feb 2011 16:38:19 +, Kai Meyer wrote:
I can't seem to use std.datetime at all. I get undefined reference on
whether I use a StopWatch, or if I just try to compile the unittest. All
I have to do is declare a StopWatch:
import std.stdio;
import std.datetime;
void main()
{
On Fri, 18 Feb 2011 17:16:02 +, Sean Eskapp wrote:
I was given this code, to check if Y is a specialization of Bar. How
does it work?
class Bar(T)
{
}
void foo(Y)()
{
static if (is(Y Z == Bar!Z))
{
// Here, Z is now an alias to whichever type Bar is //
On Fri, 18 Feb 2011 10:23:41 -0800, Jonathan M Davis wrote:
On Friday, February 18, 2011 10:12:09 Kai Meyer wrote:
Great news! Worked like a champ. Is there documentation somewhere that
I missed? I would love to be able to answer these questions on my own.
I've been stumped on this one for a
On Fri, 18 Feb 2011 20:37:38 +, Sean Eskapp wrote:
== Quote from Lars T. Kyllingstad (public@kyllingen.NOSPAMnet)'s article
On Fri, 18 Feb 2011 17:16:02 +, Sean Eskapp wrote:
I was given this code, to check if Y is a specialization of Bar. How
does it work?
class Bar(T
On Tue, 15 Feb 2011 21:32:06 +0100, Jacob Carlborg wrote:
Maybe a little off topic but does anyone know about a git library, I'll
only need to do checkouts?
Here is a C library, written by the folks behind GitHub:
https://github.com/schacon/libgit
-Lars
On Wed, 09 Feb 2011 23:01:47 -0500, Andrej Mitrovic wrote:
I'm trying to use the std.md5.sum method. It takes as an argument a
digest to output the hash to, and the second argument is plain data.
So I'm trying to read an entire file at once. I thought about using
rawRead, but I get a
On Thu, 10 Feb 2011 04:29:21 -0500, canalpay wrote:
I am trying to write the web framework(but not to write, to gain
experience.). Maybe the framework can has got a MVC desing pattern. But
first, the D2 is not has got for the web library and I am decided write
to library for web.
I am
On Thu, 10 Feb 2011 11:54:02 +, Lars T. Kyllingstad wrote:
On Thu, 10 Feb 2011 16:44:12 +0530, d coder wrote:
Greetings All
I have learnt that D has only one casting operator and that is 'cast'.
The same operator assumes different functionality depending on the
context in which it he
On Thu, 03 Feb 2011 19:11:04 +0100, spir wrote:
On 02/03/2011 02:25 PM, Lars T. Kyllingstad wrote:
On Thu, 03 Feb 2011 13:53:44 +0100, spir wrote:
On 02/03/2011 01:17 PM, Lars T. Kyllingstad wrote:
Why the reluctance to use template constraints? They're so flexible!
:)
I cannot stand
On Wed, 02 Feb 2011 17:35:50 +0100, spir wrote:
On 02/02/2011 04:20 PM, Lars T. Kyllingstad wrote:
On Wed, 02 Feb 2011 15:55:53 +0100, spir wrote:
Hello,
What are the default semantics for '==' on structs?
I ask this because I was forced to write opEquals on a struct to get
expected
On Thu, 03 Feb 2011 13:05:00 +0100, spir wrote:
On 02/03/2011 08:41 AM, Lars T. Kyllingstad wrote:
On Wed, 02 Feb 2011 18:38:02 +0100, spir wrote:
I guess the only solution would be for the compiler to support a kind
of reange type syntax?
I'm not sure I understand what you mean here
On Thu, 03 Feb 2011 13:53:44 +0100, spir wrote:
On 02/03/2011 01:17 PM, Lars T. Kyllingstad wrote:
Why the reluctance to use template constraints? They're so flexible!
:)
I cannot stand the is() idiom/syntax ;-) Dunno why. Would happily get
rid of it in favor of type-classes (built eg
On Wed, 02 Feb 2011 13:26:39 +0100, spir wrote:
Hello,
This bit of code for arrays:
Out[] map (In,Out) (In[] input, Out delegate (In) f) {
Out[] output = new Out[](input.length); foreach (i,item ; input)
output [i] = f(item);
return output;
}
unittest {
char
On Wed, 02 Feb 2011 13:18:07 +, Lars T. Kyllingstad wrote:
[...]
struct Map(Range, In, Out)
if (isInputRange!Range is(ElementType!Range : In)
{
Range input;
Out delegate(In) f;
@property bool empty() { return input.empty; }
// Inefficient
On Wed, 02 Feb 2011 15:55:53 +0100, spir wrote:
Hello,
What are the default semantics for '==' on structs?
I ask this because I was forced to write opEquals on a struct to get
expected behaviour. This struct is basically:
struct Lexeme {
string tag;
string slice;
On Wed, 02 Feb 2011 18:38:02 +0100, spir wrote:
On 02/02/2011 02:18 PM, Lars T. Kyllingstad wrote:
On Wed, 02 Feb 2011 13:26:39 +0100, spir wrote:
Hello,
This bit of code for arrays:
Out[] map (In,Out) (In[] input, Out delegate (In) f) {
Out[] output = new Out[](input.length
On Fri, 28 Jan 2011 23:30:06 -0500, Akakima wrote:
Firt, i would like to know if you are interested in receiving comments
an bug reports for DMD V1.
D1 bugs are still fixed, so bug reports are welcome.
http://d.puremagic.com/issues/
D1 has been declared stable, though, so there is usually
On Sat, 29 Jan 2011 08:47:21 +, %u wrote:
Is this a bug?
__gshared static i;
makes i be thread-local, while
static __gshared i;
makes it be shared.
If that's the case, then it is definitely a bug. The order of attributes
shouldn't matter.
-Lars
On Mon, 24 Jan 2011 10:45:03 -0500, Andrej Mitrovic wrote:
Is this a bug?
import std.stdio;
string[string] values = [abc:abc, def:def];
void main()
{
string[string] values2 = [abc:abc, def:def];
}
test.d(3): Error: non-constant expression [abc:abc,def:def]
What's
On Mon, 17 Jan 2011 17:03:15 +, Sean Eskapp wrote:
I used to use boost::bind all the time, but std.bind has me stumped, as
I keep getting static asserts with a cryptic argument has no
parameters message. At this point, the code is just:
class Foo
{
void bar(int i) { writeln(i);
On Tue, 18 Jan 2011 01:16:51 +, %u wrote:
I find it very hard to believe that struct dtors are never called.
Sorry, that part was my bad -- last time I checked, they didn't get
called, but maybe my example was too complicated, since they did get
called for a *simple* example.
On Sun, 09 Jan 2011 22:44:44 -0800, Dan Olson wrote:
I'm exploring D for embedded work as a nice alternative to C/C++ for the
32-bitters and am finding it has a nice set of features. But, what is
the best way handle memory mapped IO? I don't see volatile like in C.
Is writing asm {} the
On Fri, 07 Jan 2011 16:30:24 -0800, Jonathan M Davis wrote:
On Friday, January 07, 2011 13:32:42 Ellery Newcomer wrote:
auto a = 1, b = null;
int a = 1, *b = null;
[...]
[...]
However, I'm vere suprised that the first one succeeds. I think that it
should be reported as a bug. All
On Mon, 10 Jan 2011 08:38:15 -0800, Dan Olson wrote:
Lars T. Kyllingstad pub...@kyllingen.nospamnet writes:
On Sun, 09 Jan 2011 22:44:44 -0800, Dan Olson wrote:
I'm exploring D for embedded work as a nice alternative to C/C++ for
the 32-bitters and am finding it has a nice set of features
On Mon, 03 Jan 2011 17:18:34 -0600, Ellery Newcomer wrote:
If you're importing some other phobos module, I would guess an instance
of this bug: http://d.puremagic.com/issues/show_bug.cgi?id=314
On 01/03/2011 10:56 AM, Bryce Watkins wrote:
However when I use splitter in my code it works
On Sun, 19 Dec 2010 07:01:30 +, doubleagent wrote:
Andrei's quick dictionary illustration [in his book, 'The D Programming
Language'] doesn't seem to work. Code attached.
That's strange. I ran the example you posted using DMD 2.050 myself, and
it works for me. Are you 100% sure that
On Mon, 20 Dec 2010 18:44:12 +, doubleagent wrote:
Are you 100% sure that you are running this version
I have to be. There are no other versions of phobos on this box and
'which dmd' points to the correct binary.
dictionary[word.idup] = newId;
That fixes it.
The 'word' array
On Tue, 14 Dec 2010 09:09:33 +0100, spir wrote:
Hello,
It seems impossible to define a random-access range (opIndex + length)
alone. In fact, I cannot have it used by the language. Am I missing
something? Random-access looks enough to provide fonctionality for both
input and bidirectional
On Tue, 30 Nov 2010 18:49:56 +0300, Dmitry Olshansky wrote:
On 30.11.2010 14:59, Lars T. Kyllingstad wrote:
In my library I have a lot of functionals (functions that take other
functions as parameters). Here is an example that shows the style I
use to define them:
// Example: Evaluate
In my library I have a lot of functionals (functions that take other
functions as parameters). Here is an example that shows the style I use
to define them:
// Example: Evaluate the function/delegate/functor f at x.
auto eval(F, X)(F f, X x) { return f(x); }
// Test
void
If I've understood things correctly, by marking a delegate parameter with
'scope' you tell the compiler not to create a true closure for the
delegate. Effectively you're saying I promise not to escape this
delegate, so you don't need to copy its context to the heap.
In brief, my question is:
On Tue, 23 Nov 2010 13:15:46 +0100, spir wrote:
Hello,
alias void function (int) F;
alias void delegate (int) D;
void fnFunc (F f, int i) {f(i);}
void dgFunc (D d, int i) {d(i);}
void writeOut (int i) {writeln(i);}
void test () {
void writeIn (int i) {writeln(i);}
On Tue, 23 Nov 2010 12:25:18 +, Lars T. Kyllingstad wrote:
(For some reason the documentation for toDelegate() seems to be missing
from the D web site, but I don't know why. I'll look into it.)
Ah, found it:
http://d.puremagic.com/issues/show_bug.cgi?id=2581
-Lars
On Tue, 23 Nov 2010 13:46:19 +0100, Lutger Blijdestijn wrote:
Lars T. Kyllingstad wrote:
If I've understood things correctly, by marking a delegate parameter
with 'scope' you tell the compiler not to create a true closure for the
delegate. Effectively you're saying I promise not to escape
On Tue, 23 Nov 2010 10:17:08 +, Lars T. Kyllingstad wrote:
If I've understood things correctly, by marking a delegate parameter
with 'scope' you tell the compiler not to create a true closure for the
delegate. [...]
I just realised I posted this to the wrong group. I'll repost
I thought that the compiler could evaluate all intrinsics at compile
time, but this doesn't seem to be the case for std.math.yl2x(). Is my
assumption wrong, or is this a bug that should be reported?
-Lars
On Mon, 15 Nov 2010 13:03:03 +, div0 wrote:
On 15/11/2010 12:12, div0 wrote:
On 15/11/2010 11:00, Lars T. Kyllingstad wrote:
I thought that the compiler could evaluate all intrinsics at compile
time, but this doesn't seem to be the case for std.math.yl2x(). Is my
assumption wrong
On Wed, 10 Nov 2010 08:55:26 +0100, spir wrote:
Hello,
Is there a way for a func to hold 2 optional params of the same type?
void f(int p, bool b1=false, bool b2=false) {
writefln(p=%s b1=%s b2=%s, p,b1,b2);
}
Or is there a workaroud?
I'm not sure I understand what
On Fri, 22 Oct 2010 13:00:43 +0200, spir wrote:
Hello,
Where can one find descriptions of Throwable, Error, Exception? (I
mean, how do you even know they exist?) I could finally guess the
constructor must have a string parameter used for error output.
Well, they should be in the
On Wed, 13 Oct 2010 18:06:15 +, Lars T. Kyllingstad wrote:
On Wed, 13 Oct 2010 16:46:09 +, Nick Treleaven wrote:
Hi,
I'm new to D2 ranges but have been following D for some time. I'm
posting here because I want to check if I'm doing anything wrong before
filing a bug.
The code
On Thu, 14 Oct 2010 06:54:17 +, Lars T. Kyllingstad wrote:
On Wed, 13 Oct 2010 18:06:15 +, Lars T. Kyllingstad wrote:
On Wed, 13 Oct 2010 16:46:09 +, Nick Treleaven wrote:
Hi,
I'm new to D2 ranges but have been following D for some time. I'm
posting here because I want
On Thu, 14 Oct 2010 09:58:36 +0200, spir wrote:
Hello,
write and writeln just write; writef and writefln first format: seems
clear. But the latter do not work properly with D strings, and the
former do not work without format. Is there a practical way to just
write anything to the terminal
On Mon, 11 Oct 2010 21:46:26 +0200, Lutger wrote:
Where can I find the function to convert from c-style string to a normal
D string? It used to be toString in std.string, but that one is
deprecated.
Thanks.
import std.conv;
const char* cString;
string dString = to!string(cString)
-Lars
On Mon, 11 Oct 2010 22:00:37 +0200, Lutger wrote:
Lars T. Kyllingstad wrote:
On Mon, 11 Oct 2010 21:46:26 +0200, Lutger wrote:
Where can I find the function to convert from c-style string to a
normal D string? It used to be toString in std.string, but that one is
deprecated.
Thanks
On Fri, 08 Oct 2010 09:33:22 +0200, Benjamin Thaut wrote:
Hi, I'm writing a vec4 math struct and I have a method of which the
return value has to be a lvalue so I wonder which is the correct way to
do this:
vec4 Normalize() const { ... } //won't work, not a lvalue
ref vec4 Normalize()
On Thu, 07 Oct 2010 14:43:25 +, Benjamin Thaut wrote:
If I want to tell the compiler that a certain function argument should
not be copied (say a large struct, or a array) which is the right way to
do?
arrays:
1. function foo(in float[] bar) { ... } 2. function foo(ref
const(float[])
On Tue, 05 Oct 2010 23:25:36 +0200, vano wrote:
The code below:
module used;
import std.stdio;
class ClassA {
this() { writeln(A ctor); }
~this() { writeln(A dtor); }
}
static this() { writeln(used.sctor); } static ~this() {
I have a program that uses an immutable array, the contents of which are
known at compile time. Thus, ideally, I want it to be placed in
the .rodata segment of the program.
Firstly, I seem to remember reading that using an array literal in D will
always result in a heap allocation. Is this
On Wed, 06 Oct 2010 10:16:45 +, Lars T. Kyllingstad wrote:
static immutable int[3] = [1, 2, 3];
..should of course be
static immutable int[3] a = [1, 2, 3];
-Lars
On Wed, 06 Oct 2010 07:39:48 -0400, Steven Schveighoffer wrote:
On Wed, 06 Oct 2010 06:16:45 -0400, Lars T. Kyllingstad
pub...@kyllingen.nospamnet wrote:
[...]
Secondly, if the above is not true, how can I verify that the array in
the following piece of code isn't allocated and/or copied
On Tue, 05 Oct 2010 12:50:44 +0100, Bob Cowdery wrote:
On 05/10/2010 12:40, Bob Cowdery wrote:
On 05/10/2010 12:13, Denis Koroskin wrote:
On Tue, 05 Oct 2010 15:08:39 +0400, Bob Cowdery
b...@bobcowdery.plus.com wrote:
On 05/10/2010 12:04, Denis Koroskin wrote:
On Tue, 05 Oct 2010
On Sun, 26 Sep 2010 20:55:33 +0200, Tom Kazimiers wrote:
If I would use std.stdio.File, what would be different?
Well, for one thing you won't have to write your code all over again when
std.stream is deprecated, which will happen soon. std.stdio.File is
really what you should use for file
On Sat, 18 Sep 2010 07:15:35 -0400, Sam Hu wrote:
Greetings!
I want to have a try on dflplot.But I don't find module dstats.all which
is used by dflplot.d,could anybody let me where it is?
Thank you.
Hi!
David Simcha (the dflplot author) has changed the name of the library to
On Wed, 18 Aug 2010 13:50:34 -0400, Nick Sabalausky wrote:
Steven Schveighoffer schvei...@yahoo.com wrote in message
news:op.vhl46mdneav...@localhost.localdomain...
Changes are afoot to std.process, we recently got a blocker fixed (not
yet in svn, but someone submitted a correct patch)
On Sat, 14 Aug 2010 14:58:05 +0200, simendsjo wrote:
c:\temp\src\test.d
c:\temprdmd src\test
The system cannot find the path specified.
c:\temprdmd src/test
std.file.FileException: (...)\.rdmd\rdmd-src/test.d-(...): The system
cannot find the path specified.
Using rdmd 20090902, dmd
On Mon, 09 Aug 2010 17:35:56 -0700, Jonathan M Davis wrote:
On Monday, August 09, 2010 17:09:03 simendsjo wrote:
On 10.08.2010 02:09, Jonathan M Davis wrote:
On Monday, August 09, 2010 16:59:07 bearophile wrote:
simendsjo:
Ahem.. :) Yes, I did miss your answer! How I got fooled by the
On Tue, 10 Aug 2010 01:48:17 -0700, Jonathan M Davis wrote:
On Tuesday 10 August 2010 00:30:37 Lars T. Kyllingstad wrote:
No, using 'is' won't work. Check this out:
int[] a;
assert (a == null);
assert (a is null);
a = new int[10];
a.length = 0;
assert (a == null
On Tue, 10 Aug 2010 07:50:34 -0400, bearophile wrote:
Lars T. Kyllingstad:
There, I don't agree with you. Arrays are a sort of pseudo-reference
type, so I don't mind 'null' being a sort of pseudo-null in that
context. Actually, I find it to be quite elegant. It's a matter of
taste, I
On Mon, 09 Aug 2010 07:31:21 -0400, bearophile wrote:
Jonathan M Davis:
Well, the requirement for save() being part of a forward range is
fairly recent, and a bunch of ranges which are supposed to be forward
ranges don't have them even though they're supposed to. The change was
made fairly
On Mon, 09 Aug 2010 10:35:02 -0400, Steven Schveighoffer wrote:
On Mon, 09 Aug 2010 10:27:09 -0400, Don nos...@nospam.com wrote:
Steven Schveighoffer wrote:
On Mon, 09 Aug 2010 09:57:47 -0400, bearophile
bearophileh...@lycos.com wrote:
Steven Schveighoffer:
I thought it was you're on
On Mon, 09 Aug 2010 18:58:36 +0200, simendsjo wrote:
The documentation says
/***
* Returns s[] sans trailing delimiter[], if any. * If delimiter[] is
null, removes trailing CR, LF, or CRLF, if any. */
To adhere to the documentation, chomp must be
On Thu, 29 Jul 2010 22:55:35 -0400, bearophile wrote:
RedZone:
But it would be nice if I could have the array reference itself be
immutable and not just the array's contents. Is there any way I could
do this?
Let's say your code is as your second example:
class Foo {
private:
On Mon, 19 Jul 2010 18:01:25 -0400, bearophile wrote:
typedef char* Cstring;
extern(C) Cstring strcmp(Cstring s1, Cstring s2); ...
You can use just a struct too:
import std.string: toStringz;
struct Cstring {
const(char)* ptr;
}
extern(C) Cstring strcmp(Cstring s1, Cstring
= red;
auto r2 = strcmp(Cstring(s1), Cstring(s2));
}
Lars T. Kyllingstad:
but I think it should wrap a ubyte*, not a char*. The reason for this
is that D's char is supposed to be a UTF-8 code unit, whereas C's char
can be anything.
Right. But toStringz() returns a const(char)*, so
On Tue, 20 Jul 2010 13:26:56 +, Lars T. Kyllingstad wrote:
On Tue, 20 Jul 2010 14:59:18 +0200, awishformore wrote:
Following this discussion on announce, I was wondering why string
literals are zero-terminated. Or to re-formulate, why only string
literals are zero-terminated. Why
On Sun, 18 Jul 2010 13:08:57 -0700, Charles Hixson wrote:
I'm trying to link a C routine to a D program, passing string
parameters, but I keep getting segmentation errors. As you can see,
these are simple test routines, so the names don't reflect current
status, but merely where I intend to
On Fri, 16 Jul 2010 11:46:48 +0200, Rory McGuire wrote:
import std.stdio;
struct State {
string s; string getString() { return s; } static State opCall(string
s) {
State ret;
ret.s = s;
return ret;
}
}
void main() {
auto s = State(adf);
pragma(msg, s.getString());
On Wed, 14 Jul 2010 16:57:13 -0400, Heywood Floyd wrote:
Lars T. Kyllingstad Wrote:
But then arrays would be different from all other types! If you have
an array of 3 Ts, that is written T[3], regardless of what T is. Now
consider these two cases:
A. T is an int. Then T[3
Is object.reserve() only useful for large arrays, or should I always use
it if I intend to append to an array?
Let's say I want to read some data, and I expect there to be ~100 bytes
of data. Is there any point in using reserve() first, or will there
always be that much memory available to an
On Wed, 14 Jul 2010 10:35:19 -0400, Steven Schveighoffer wrote:
On Wed, 14 Jul 2010 06:01:10 -0400, Lars T. Kyllingstad
pub...@kyllingen.nospamnet wrote:
Is object.reserve() only useful for large arrays, or should I always
use it if I intend to append to an array?
Let's say I want to read
On Mon, 12 Jul 2010 17:23:16 -0400, Heywood Floyd wrote:
bearophile Wrote:
Heywood Floyd:
This had me crazy. I ended up putting the brackets on the variable,
like
int marr[3][5];
then it worked like
marr[2][4] = 9;
That's present only for compatibility with C syntax, this
On Sun, 11 Jul 2010 23:25:32 -0700, Jonathan M Davis wrote:
Okay. There are cases where you want a constructor to do something when
the class/struct is created, and you want the destructor to do something
when the class/struct goes out of scope. A classic example would be an
autolock for a
On Mon, 21 Jun 2010 14:07:19 -0400, Chick Corea wrote:
Using dmd v2.0.47, the following code:
import core.sys.posix.pwd;
import core.sys.posix.grp;
yields the following error message:
Error: module grp is in file 'core/sys/posix/grp.d' which cannot
be
On Thu, 17 Jun 2010 21:31:10 +, Byron Heads wrote:
is setMaxMailboxSize not implemented yet or is it bugged?
It seems it got implemented today. :)
http://www.dsource.org/projects/phobos/changeset/1662
You can use the SVN version of Phobos, or wait for the next release.
-Lars
On Thu, 17 Jun 2010 20:09:29 +, Byron Heads wrote:
Whats the proper way to get access to some of the Posix functions?
ie. fork setsid...
import core.sys.posix.unistd; //? Is it proper to import from core.sys
Yes, that is correct. :)
-Lars
On Tue, 08 Jun 2010 11:23:23 +0100, Patrick Byrne wrote:
Amazon (UK) tells me that publication of this book is delayed. Is it
still coming soon, please?
I also ordered it from Amazon UK, and got the same message. But the book
is, as far as I know, finished and printed. So I suppose it's
On Tue, 08 Jun 2010 12:39:43 +0200, Simen kjaeraas wrote:
Simen kjaeraas simen.kja...@gmail.com wrote:
Lars T. Kyllingstad pub...@kyllingen.nospamnet wrote:
FWIW, I've run across the same error, while writing code that had
nothing
to do with tuples. And I've seen others complaining about
On Tue, 08 Jun 2010 12:56:04 +0200, Simen kjaeraas wrote:
Lars T. Kyllingstad pub...@kyllingen.nospamnet wrote:
That's consistent with my experiences too. It seems to be triggered by
a Phobos unittest.
Still, I can't reproduce it with your test case. Which DMD version are
you using
On Tue, 08 Jun 2010 13:00:51 +0100, Robert Clipsham wrote:
On 08/06/10 11:23, Patrick Byrne wrote:
Amazon (UK) tells me that publication of this book is delayed. Is it
still coming soon, please?
--
Patrick Byrne
I ordered it from amazon.com, it was half the priceof the UK version ;)
I
In D2, what is the effect (if any) of 'scope' in the following situations?
scope int a;
struct B { ... }
scope B b;
scope int[] c;
// According to the spec, 'in' is shorthand for 'const scope'.
void foo(in char[] d) { ... }
Thanks,
-Lars
On Fri, 14 May 2010 02:38:40 +, kai wrote:
Hello,
I was evaluating using D for some numerical stuff. However I was
surprised to find that looping array indexing was not very speedy
compared to alternatives (gcc et al). I was using the DMD2 compiler on
mac and windows, with -O
1 - 100 of 184 matches
Mail list logo