Sorry. The previous is not the one causes the problem.
Try this:
struct S {
string str = Hello; // Adding an initial value here.
};
S g_s;
unittest {
S s1;
S s2;
assert(s1 == s2); // Success
assert(g_s == s1); // Fail
auto s3 = g_s;
assert(s3 == g_s);; // Even this
On Wednesday, October 12, 2011 06:07:38 Cheng Wei wrote:
Sorry. The previous is not the one causes the problem.
Try this:
struct S {
string str = Hello; // Adding an initial value here.
};
S g_s;
unittest {
S s1;
S s2;
assert(s1 == s2); // Success
assert(g_s
Thanks. Removing the ';' after struct and class is really helpful. The
; keeps trapping me in C++ coding. :)
The following expression compiles but does not make sense.
string str = hello ~ 10;
assert(str == hello\n);
Is this a useful feature or just a bug?
On Wednesday, October 12, 2011 07:08:05 Cheng Wei wrote:
The following expression compiles but does not make sense.
string str = hello ~ 10;
assert(str == hello\n);
Is this a useful feature or just a bug?
int and dchar implicitly convert to one another for better or for worse.
Cheng Wei:
string str = hello ~ 10;
assert(str == hello\n);
Is this a useful feature or just a bug?
I'd call it trash-feature :-|
Bye,
bearophile
Jonathan M Davis:
int and dchar implicitly convert to one another for better or for worse.
Personally, I'd prefer that they didn't, but that's the way that it is, so I
don't believe that this is technically a bug.
char-int is OK, but int-char is not so OK. This programs (that compiles with
On Wednesday, October 12, 2011 03:53:22 bearophile wrote:
Jonathan M Davis:
int and dchar implicitly convert to one another for better or for worse.
Personally, I'd prefer that they didn't, but that's the way that it is,
so I don't believe that this is technically a bug.
char-int is OK,
On 12.10.2011 10:14, Jonathan M Davis wrote:
On Wednesday, October 12, 2011 06:07:38 Cheng Wei wrote:
Sorry. The previous is not the one causes the problem.
Try this:
struct S {
string str = Hello; // Adding an initial value here.
};
S g_s;
unittest {
S s1;
S s2;
Le 12/10/2011 09:53, bearophile a écrit :
Jonathan M Davis:
int and dchar implicitly convert to one another for better or for worse.
Personally, I'd prefer that they didn't, but that's the way that it is, so I
don't believe that this is technically a bug.
char-int is OK, but int-char is not
I believe that the primary reasoning for allowing the implicit conversion
between int and dchar is so that code like this
dchar c = 'a' + 7;
That's a '+' though, not a '~'.
I think it shouldn't be allowed with ~ since it's misleading.
Newbies would probably expect abc ~ 10 to yield abc10
On Wed, 12 Oct 2011 09:46:57 -0400, Trass3r u...@known.com wrote:
I believe that the primary reasoning for allowing the implicit
conversion
between int and dchar is so that code like this
dchar c = 'a' + 7;
That's a '+' though, not a '~'.
Jonathan meant this better example ;)
string s =
On Tue, 11 Oct 2011 12:40:29 -0400, Andrej Mitrovic
andrej.mitrov...@gmail.com wrote:
Nope. Private ctors have to be called from within the same module,
whether implicit or not:
test.d:
class Foo
{
private this() { } // Error: constructor main.Bar.this no match
for implicit super() call
On Sun, 09 Oct 2011 13:52:47 -0400, bearophile bearophileh...@lycos.com
wrote:
(I show this here because it's probably a silly idea, but it may a
chance to learn something.)
Do you like the idea of a POD that is always managed by reference, as
class instances?
ref struct Foo {}
static
On Mon, 10 Oct 2011 15:42:26 -0400, simendsjo simend...@gmail.com wrote:
On 10.10.2011 21:38, bearophile wrote:
%u:
Decho hello | wordcount2.exe wordcount2.d
0 hello
std.stdio.StdioException@std\stdio.d(2156): Bad file descriptor
This is a bug in the C runtime that D uses, where
Hi,
I try to write a DLL in D which could be called from C#. For testing I want
to write a Concatenate method. The call to the DLL method does not raise
any exception in C# but the out string strResult is empty or it contains
invalid characters.
I tested it with strcopy, toStringz, string.ptr and
[DllImport(mydll.dll,
CallingConvention = CallingConvention.Cdecl,
SetLastError = false, CharSet = CharSet.Auto)]
private static extern bool concatenate(
string str1, // in
string str2, // in
StringBuilder
reservastranc...@gmail.com
reservastrancoso @ gmail.com
(reservastranc...@gmail.com)
Pousadas em Trancoso, agencia virtual em Tancoso - Bahia. Faça ja sua reserva
nas pousadas mais badaladas da cidade.
Contato reservastrancoso @ gmail.com
reservastranc...@gmail.com
On Wed, 12 Oct 2011 17:10:09 +0100, Trass3r u...@known.com wrote:
[DllImport(mydll.dll,
CallingConvention = CallingConvention.Cdecl,
SetLastError = false, CharSet = CharSet.Auto)]
private static extern bool concatenate(
string str1, //
This is in relation to my sorting algorithm. This is what I need to
accomplish with ranges in the most efficient way possible:
1. Merge sort - This involves copying elements to a temporary buffer,
which can simply be an array, then merging the two lists together. The
important thing is that
On Wed, 12 Oct 2011 18:00:10 +0200, Andre an...@s-e-a-p.de wrote:
Hi,
I try to write a DLL in D which could be called from C#. For testing I
want
to write a Concatenate method. The call to the DLL method does not raise
any exception in C# but the out string strResult is empty or it contains
On 11/10/2011 18:12, Justin Whear wrote:
From the docs:
Different signals can be added to a class by naming the mixins.
So I think something like this ought to work:
mixin Signal!(string) onBlah;
mixin Signal!(int, int) onClicketyClick;
Peter Ravinovich wrote:
Is there a way to have
On 12.10.2011 22:23, Xinok wrote:
This is in relation to my sorting algorithm. This is what I need to
accomplish with ranges in the most efficient way possible:
1. Merge sort - This involves copying elements to a temporary buffer,
which can simply be an array, then merging the two lists
Yes, the docs don't elaborate or include an example. So, for posterity's
sake here's a quick example:
import std.stdio,
std.signals;
void main()
{
auto foo = new Foo;
auto listener = new Listener;
Dear Friends,
Here is the QUESTION:
Does anyone know of any good books that talk about how computers work
abstractly enough to be a solid cross language foundation?
To put this question another way, I REALLY want to actually understand The D
Programming Language by Andrei Alexandrescu. I
Here's a classic:
http://en.wikipedia.org/wiki/Structure_and_Interpretation_of_Computer_Programs
A video series by the authors (from the 80s I believe) was recently made
freely available and I found it really fascinating though I was already
familiar with the content. Highly recommended:
I've started in java with the book java for students at the age of 13, it
was a very well-written book and easy to understand so I bought another book
from that author vb.net for students. fascinated by one of the last
chapters which went 'under the hood' I searched some more about compilation
and
One really good book I read ages ago that takes the magic away from c++
and talks about how it's translated into an underlying implementation is
Inside the C++ Object Model by Stanley Lippman. While it's written with
c++ in mind, it's details can be abstracted to just about any object
On Wed, 12 Oct 2011 21:10:00 +, Louis wrote:
Does anyone know of any good books that talk about how computers work
abstractly enough to be a solid cross language foundation?
[...]
There is no Beginning D or D For Dummies yet.
There is a Turkish D book that targets programming novices:
Johannes Pfau made an updated version of std.signals, I think he's
hosting it somewhere on his dropbox, you'll have to ask him.
This code, that a sane language/language implementation refuses at
compile-time, runs:
import std.stdio;
void main() {
writefln(%d, hello);
}
And it outputs:
['h', 'e', 'l', 'l', 'o']
Is this good/expected/acceptable/buggy?
Bye,
bearophile
That's a sweet trick right there. I get different results but I guess
this is due to new std.format changes:
[104, 101, 108, 108, 111]
Did D2 ever implement the Eiffel old construct? I do not see it
mentioned in The D Programming Language, and the only reference I can
find in the newsgroup is a short discussion in June of 2007 that seemed
to go nowhere.
If not, has anyone developed a reasonable workaround? Thanks.
--
33 matches
Mail list logo