On 2011-09-21 02:18, Andrej Mitrovic wrote:
Won't compile for obvious reasons:
struct Bar { }
struct Foo
{
this(Bar bar, int line = __LINE__)
{
pragma(msg, "Warning: Constructing Foo with Bar incurs
precision loss. Line: " ~ line);
}
}
void main()
{
auto foo = Foo(B
On Wednesday, September 21, 2011 04:40:34 Cheng Wei wrote:
> Thanks a lot.
> Weird. It is not in the library reference in http://www.d-programming-
> language.org/, but it is in the library reference in digitalmars.com. I
> throught the previous one was the official web site now. It seems it
> stil
Thanks a lot.
Weird. It is not in the library reference in http://www.d-programming-
language.org/, but it is in the library reference in digitalmars.com. I
throught the previous one was the official web site now. It seems it
still is not synced well.
import std.process;
void main() {
execvp("ip", ["route"]);
}
result:
Object "ute" is unknown, try "ip help".
So the first two bytes are lost.
After adding two spaces in the first argument, it works.
import std.process;
void main() {
execvp("ip", [" route"]);
}
dmd 2.055 linux 32bit.
Is
#import std.process
void main() {
execvp("ip", "route");
}
result:
Object "ute" is unknown, try "ip help".
That is the first two bytes are lost
Adding two spaces works:
#import std.process
void main() {
execvp("ip", " route");
}
Version 2.055, linux, 32bit
Thanks.
On Tue, 20 Sep 2011 14:28:54 -0400, Steven Schveighoffer wrote:
> You can deallocate the original array. The soon-to-be-deprecated method
> (but easiest) is:
>
> delete t;
>
> To avoid having to change your other code, I'd do this:
>
> wchar[] t = ...;
> scope(exit) delete t; // add this line
On Wednesday, September 21, 2011 03:31:11 Cheng Wei wrote:
> In D2, how can we get the output of running a script.
> We can use 'system' to run the script, but how we cannot assign the
> standard output of the running script. Is there any way to do it, or
> whether it will be included into future v
In D2, how can we get the output of running a script.
We can use 'system' to run the script, but how we cannot assign the
standard output of the running script. Is there any way to do it, or
whether it will be included into future version of std.process? Thanks a
lot.
On 9/21/11, Adam D. Ruppe wrote:
> I'd suggest having a version(warnings_suck) { static assert(0); }
> so people who want more info can just stick a -version= on the build
> and get the compiler's help.
Yeah that was already planned, no worries. :)
I'd suggest having a version(warnings_suck) { static assert(0); }
so people who want more info can just stick a -version= on the build
and get the compiler's help.
static assert(0) gives a kind of compile time stack trace.
On Tuesday, September 20, 2011 21:48:10 Christophe wrote:
> > To avoid having to change your other code, I'd do this:
> >
> > wchar[] t = ...;
> > scope(exit) delete t; // add this line to the end of the function (after
> > returning)
> >
> > There is another way, but it's not as easy:
> >
> > /
Ah, you're right. It should have been a compile-time argument, conv.to
actually works in CTFE:
import std.conv;
struct Bar { }
struct Foo
{
this(int line = __LINE__)(Bar bar)
{
pragma(msg, "Warning: Constructing Foo with Bar incurs
precision loss. Line: " ~ to!string(line));
}
}
On Tuesday, September 20, 2011 17:18 Andrej Mitrovic wrote:
> Won't compile for obvious reasons:
>
> struct Bar { }
> struct Foo
> {
> this(Bar bar, int line = __LINE__)
> {
> pragma(msg, "Warning: Constructing Foo with Bar incurs
> precision loss. Line: " ~ line);
> }
> }
>
> void main()
> {
> a
Timon Gehr , dans le message (digitalmars.D.learn:29641), a écrit :
>> Last point: WalkLength is not optimized for strings.
>> std.utf.count should be.
>>
>> This short implementation of count was 3 to 8 times faster than
>> walkLength is a simple benchmark:
>>
>> size_t myCount(string text)
>> {
>
Won't compile for obvious reasons:
struct Bar { }
struct Foo
{
this(Bar bar, int line = __LINE__)
{
pragma(msg, "Warning: Constructing Foo with Bar incurs
precision loss. Line: " ~ line);
}
}
void main()
{
auto foo = Foo(Bar());
}
That's just an example, but I want to iss
On 09/21/2011 01:57 AM, Christophe wrote:
"Jonathan M Davis" , dans le message (digitalmars.D.learn:29637), a
écrit :
On Tuesday, September 20, 2011 14:43 Andrej Mitrovic wrote:
On 9/20/11, Jonathan M Davis wrote:
Or std.range.walkLength. I don't know why we really have std.utf.count. I
jus
"Jonathan M Davis" , dans le message (digitalmars.D.learn:29637), a
écrit :
> On Tuesday, September 20, 2011 14:43 Andrej Mitrovic wrote:
>> On 9/20/11, Jonathan M Davis wrote:
>> > Or std.range.walkLength. I don't know why we really have std.utf.count. I
>> > just
>> > calls walkLength anyway. I
On Tuesday, September 20, 2011 15:10 Andrej Mitrovic wrote:
> On 9/20/11, Jonathan M Davis wrote:
> > We specifically avoid having aliases in Phobos simply for having
> > alternate function names. Aliases need to actually be useful, or they
> > shouldn't be there.
>
> And function names have to b
On 9/20/11, Jonathan M Davis wrote:
> We specifically avoid having aliases in Phobos simply for having alternate
> function names. Aliases need to actually be useful, or they shouldn't be
> there.
And function names have to be useful to library users. walkLength is
an awful name for something tha
On Tuesday, September 20, 2011 14:43 Andrej Mitrovic wrote:
> On 9/20/11, Jonathan M Davis wrote:
> > Or std.range.walkLength. I don't know why we really have std.utf.count. I
> > just
> > calls walkLength anyway. I suspect that it's a function that predates
> > walkLength and was made to use walk
> To avoid having to change your other code, I'd do this:
>
> wchar[] t = ...;
> scope(exit) delete t; // add this line to the end of the function (after
> returning)
>
> There is another way, but it's not as easy:
>
> // put this at the top of file
> import core.memory;
>
> ...
>
> scope(ex
One other thing, count can only take an array which seems too
restrictive since walkLength can take any range at all. So maybe count
should be just an alias to walkLength or it should possibly be removed
(I'm against fully removing it because I already use it in code and I
think the name does make
On 9/20/11, Jonathan M Davis wrote:
> Or std.range.walkLength. I don't know why we really have std.utf.count. I
> just
> calls walkLength anyway. I suspect that it's a function that predates
> walkLength and was made to use walkLength after walkLength was introduced.
> But
> it's kind of pointless
On Tuesday, September 20, 2011 14:27 Andrej Mitrovic wrote:
> Don't use length, use std.utf.count, ala:
>
> import std.utf;
> alias toUTFz!(const(wchar)*, string) toUTF16z;
> GetTextExtentPoint32W(str.toUTF16z, std.utf.count(str), s);
Or std.range.walkLength. I don't know why we really have std.u
Don't use length, use std.utf.count, ala:
import std.utf;
alias toUTFz!(const(wchar)*, string) toUTF16z;
GetTextExtentPoint32W(str.toUTF16z, std.utf.count(str), s);
I like to keep that alias for my code since I was already using it beforehand.
I'm pretty sure (ok maybe 80% sure) that GetTextExt
Steven Schveighoffer:
> BTW, when posting questions like this, it is *immensely* helpful to give
> exact error messages,
I have forgotten to do that by mistake. I am sorry.
Bye,
bearophile
Does it 'leak'? What is your exact setup, why isn't the GC collecting
that memory?
I have a Label class with a text() property that calls the procedure
that I have written in my first post and returns the result.
I have posted here because I was looking the memory usage (more
precisely th
Am Tue, 20 Sep 2011 20:44:40 +0200 schrieb Timon Gehr:
> On 09/20/2011 08:24 PM, Timon Gehr wrote:
>> On 09/20/2011 08:07 PM, Andre wrote:
>>> Am Tue, 20 Sep 2011 19:27:03 +0200 schrieb Trass3r:
>>>
> bool test(HDC dc, string str, int len, SIZE* s)
> {
> wchar[] wstr = toUTFz!(wchar*)s
On 09/20/2011 08:24 PM, Timon Gehr wrote:
On 09/20/2011 08:07 PM, Andre wrote:
Am Tue, 20 Sep 2011 19:27:03 +0200 schrieb Trass3r:
bool test(HDC dc, string str, int len, SIZE* s)
{
wchar[] wstr = toUTFz!(wchar*)str;
GetTextExtentPoint32W(dc wstr.ptr, wstr.length, s);
toUTFz returns a wchar*,
On 09/20/2011 08:34 PM, Trass3r wrote:
Are you sure that the call requires the string to be null terminated?
I do not know that winapi function, but this might work:
bool test(HDC dc, string str, SIZE* s)
{
auto wstr = to!(wchar[])str;
GetTextExtentPoint32W(dc, wstr.ptr, wstr.length, s);
...
I
Are you sure that the call requires the string to be null terminated? I
do not know that winapi function, but this might work:
bool test(HDC dc, string str, SIZE* s)
{
auto wstr = to!(wchar[])str;
GetTextExtentPoint32W(dc, wstr.ptr, wstr.length, s);
...
It doesn't need to be null-terminated f
On 09/20/2011 08:06 PM, Dax wrote:
Hi!
I'm working on a library written in D.
After some tests I have discovered that my library leaks memory, those leaks
are caused by dynamics array that I use in my library.
Does it 'leak'? What is your exact setup, why isn't the GC collecting
that memory?
On Tuesday, September 20, 2011 11:06 Dax wrote:
> Hi!
> I'm working on a library written in D.
> After some tests I have discovered that my library leaks memory, those
> leaks are caused by dynamics array that I use in my library.
>
> My question is:
> Should dynamics array be deallocated automati
On Tue, 20 Sep 2011 14:06:34 -0400, Dax wrote:
Hi!
I'm working on a library written in D.
After some tests I have discovered that my library leaks memory, those
leaks are caused by dynamics array that I use in my library.
My question is:
Should dynamics array be deallocated automatically wh
On 09/20/2011 08:07 PM, Andre wrote:
Am Tue, 20 Sep 2011 19:27:03 +0200 schrieb Trass3r:
bool test(HDC dc, string str, int len, SIZE* s)
{
wchar[] wstr = toUTFz!(wchar*)str;
GetTextExtentPoint32W(dc wstr.ptr, wstr.length, s);
toUTFz returns a wchar*, not a wchar[].
I am not familiar with po
Hi!
I'm working on a library written in D.
After some tests I have discovered that my library leaks memory, those leaks
are caused by dynamics array that I use in my library.
My question is:
Should dynamics array be deallocated automatically when a procedure returns?
There is another way to acom
Am Tue, 20 Sep 2011 19:27:03 +0200 schrieb Trass3r:
>> bool test(HDC dc, string str, int len, SIZE* s)
>> {
>> wchar[] wstr = toUTFz!(wchar*)str;
>> GetTextExtentPoint32W(dc wstr.ptr, wstr.length, s);
>
> toUTFz returns a wchar*, not a wchar[].
I am not familiar with pointers. I know I have to
c
On 09/20/2011 08:46 AM, Jonathan M Davis wrote:
I don't believe that it doesn't currently work with 64-bit binaries though,
You could use oprofile in that case.
http://oprofile.sourceforge.net/
--
Mike Wey
bool test(HDC dc, string str, int len, SIZE* s)
{
wchar[] wstr = toUTFz!(wchar*)str;
GetTextExtentPoint32W(dc wstr.ptr, wstr.length, s);
toUTFz returns a wchar*, not a wchar[].
Hi,
I want something like:
bool test(HDC dc, string str, int len, SIZE* s)
{
wchar[] wstr = toUTFz!(wchar*)str;
GetTextExtentPoint32W(dc wstr.ptr, wstr.length, s);
...
I get the wchar[] stuff not working. I am struggling
with pointer to array. Could you give some advice?
Kind regards
Andre
"Steven Schveighoffer" wrote in message
news:op.v13w8td2eav7ka@localhost.localdomain...
> On Tue, 20 Sep 2011 07:33:20 -0400, bearophile
> wrote:
>
>> void foo(const ref int[5] a) {}
>> void main() {
>> immutable int[5] arr;
>> foo(arr); // Error?
>> }
>
> The complaint from the compile
20.09.2011 9:55, Jonathan M Davis пишет:
Someone who has actually done a C or C++ application or two which used D code
should answer this question. I know that there are at least a few folks around
here who have done that, but I've never done it myself.
http://stackoverflow.com/questions/7480046
On Tue, 20 Sep 2011 07:33:20 -0400, bearophile
wrote:
In this bug report I have asked for better error messages:
http://d.puremagic.com/issues/show_bug.cgi?id=6696
But beside the error message, do you know why an immutable ref can't be
given to a function with a const ref argument? foo() c
On Tue, 20 Sep 2011 07:33:20 -0400, bearophile
wrote:
In this bug report I have asked for better error messages:
http://d.puremagic.com/issues/show_bug.cgi?id=6696
But beside the error message, do you know why an immutable ref can't be
given to a function with a const ref argument? foo() c
bearophile Wrote:
> In this bug report I have asked for better error messages:
> http://d.puremagic.com/issues/show_bug.cgi?id=6696
>
> But beside the error message, do you know why an immutable ref can't be given
> to a function with a const ref argument? foo() can't change the contents of
> t
Christophe:
> I don't think it is wrong. Did you try changind the order of const and
> ref, or adding parenthesis ?
I am trying now, and it seems the situation doesn't change.
Bye,
bearophile
bearophile , dans le message (digitalmars.D.learn:29609), a écrit :
> what's wrong in this code?
>
>
> void foo(const ref int[5] a) {}
> void main() {
> immutable int[5] arr;
> foo(arr); // Error?
> }
I don't think it is wrong. Did you try changind the order of const and
ref, or adding
In this bug report I have asked for better error messages:
http://d.puremagic.com/issues/show_bug.cgi?id=6696
But beside the error message, do you know why an immutable ref can't be given
to a function with a const ref argument? foo() can't change the contents of the
array a any way, so what's w
On Mon, 19 Sep 2011 23:09:45 +0100, Simen Kjaeraas
wrote:
On Mon, 19 Sep 2011 23:20:47 +0200, bearophile
wrote:
A tiny puzzle I've shown on IRC. This is supposed to create an inverted
array of cards, but what does it print instead?
import std.stdio, std.algorithm, std.range;
void main
Jonathan M Davis Wrote:
> Someone who has actually done a C or C++ application or two which used D code
> should answer this question. I know that there are at least a few folks
> around
> here who have done that, but I've never done it myself.
>
> http://stackoverflow.com/questions/7480046/im
50 matches
Mail list logo