Max Samukha wrote:
>
> this.classinfo can be seen as a virtual function returning the
> classinfo for the actual class instance and typeof(this).classinfo -
> as a static function returning the classinfo of the compile-time type
> of this (that is the class where it is called). So, your example
>
Michal Minich wrote:
>
> btw. I noticed that you are using "+" for string concatenation, how is
> possible that your program even comiples??? "~" should be used for string
> concatenation.
sorry, it was my type error. the code is not real ^^)
Hi All,
I want to print some object information for debugging. But the name of class
is incorrect. I do not know why.
module test;
class A {
char[] data;
public char[] toString() {
return "<" + this.classinfo.name + ": " + data + ">";
}
}
class B: A {
char[] data2;
public overri
Eldar Insafutdinov wrote:
>
> You only have to use scope for top-level QObject subclasses. For anything
> else you should use auto. Nevertheless, it would be useful if you submit a
> bug report.
Even when my application is multi-thread? I am not sure, if I can declare
QPixmap also as "auto"
er the old instance, where the variable regionA previously was pointed
to, still exists.
I cannot reproceduce this problem with simple D data types.
But do you think this is a bug of dmd 1.051?
Qian Xu
Eldar Insafutdinov wrote:
>
> All Qt versions keep forward binary compatibility and a full compatibility
> within a major version, 4.5.3 contains only bug fixes compared to 4.5.2.
> Version from code.google.com is a way to old, so I would not even
> consider it. Have you tried to turn on BUILD
Eldar Insafutdinov wrote:
>
> I saw you made the reference to this link
> (http://www.dsource.org/projects/qtd/wiki/MacCaseStudy which contains this
> command line option, but still I don't understand why you get undefined
> symbols like QPrintDialog::options() const which belongs to libQtGui.
Be
albatroz Wrote:
> Eldar Insafutdinov wrote:
>
> > Qian Xu Wrote:
> >
> >> Hi All,
> >>
> >> I have almost built the first demo, but ...
> >> The components I have are as follows:
> >> 1. QtK SDK (LGPL edition) 4.5.3
> >
Hi All,
I have almost built the first demo, but ...
The components I have are as follows:
1. QtK SDK (LGPL edition) 4.5.3
2. the latest svn version of QtD (trunk-r309.zip)
3. DMD 1.050
4. Tango (current from trunk)
5. Platform: openSUSE 11.1.
6. cmake 2.6
After QtD was built successfully, I try
Chris Nicholson-Sauls wrote:
> Qian Xu wrote:
>> Hi All,
>>
>> a function is declared as follows:
>>
>> class Foo
>> {
>> final Value array(...)
>> {
>> ...
>> }
>> }
>>
>>
>> I can
Hi All,
a function is declared as follows:
class Foo
{
final Value array(...)
{
...
}
}
I can pass any number of parameters to this method array() like:
auto foo = new Foo;
foo.array(1, 2, 3);
But if I have only an array in hand, how to pass it to this method? Is
Stewart Gordon wrote:
> Qian Xu wrote:
>> Hi All,
>>
>> I found out that dmd does not show warnings by casting int to uint.
>
>
> Known bug.
>
> http://d.puremagic.com/issues/show_bug.cgi?id=259
>
> Stewart.
thanks, good to know that. i thought i have not configured dmd correctly ^^)
Hi All,
I found out that dmd does not show warnings by casting int to uint.
demo code looks as follows:
---
module main;
void main()
{
uint positive = 10;
int negative = -1;
assert(negative < positive); // did not pass
}
-
Steven Schveighoffer wrote:
> On Mon, 04 May 2009 09:46:57 -0400, Qian Xu
> wrote:
>
>> Hi All,
>>
>> The following code will throw an exception:
>> char[] s;
>> assert( s.dup is null); // OK
>> assert("".dup !is null); // FAILED
&g
Steven Schveighoffer wrote:
> I think you might have a bug?
>
> "".dup is the same as s.dup, not sure why you would expect it to be
> not-null.
>
> -Steve
If I have not explained clearly.
Here is the full code:
char[] s;
assert(s is null);
assert(s.dup is null);
assert("" !is
Hi All,
The following code will throw an exception:
char[] s;
assert( s.dup is null); // OK
assert("".dup !is null); // FAILED
"".dup is expectly also an empty string.
Is this a compiler bug?
--Qian
grauzone wrote:
>
> class A {
> B b;
> }
>
> class B {
> A a;
> }
>
> auto a = new A();
> auto b = new B();
> a.b = b;
> b.a = a;
>
> Your recursive approach wouldn't quite work with that. Before cloning an
> object, you'll first have to check if the object was already cloned. If
> this is the
grauzone wrote:
> ...
> cloned = clone(yourobject);
Hi again.
There are two things on my side:
1. Compiler refuses to clone private attributes. I have tried
gdc/gdmd/dmd_v1 in Linux.
2. I have implemented an example. But some part not implemented.
- code ---
grauzone wrote:
> newobject.tupleof[i] = old.tupleof[i];
If the current value of tupleof[i] is an object, the object will be
referenced, won't it?
Shall I write:
auto elem = old.tupleof[i];
static if (is(typeof(elem) == class))
{
newobject.tupleof[i] = clone(elem);
}
else
{
Hi All,
is there any (easy) way to clone an object or any other classes?
--Qian
Adam Burton wrote:
I wouldn't think so, cos LinkSeq!(Apple) does not inherit LinkSeq!(Fruit),
they are 2 separate types. However your apples automatically downcast (or
up, depending which way you like to draw your diagrams :-) ) so unless you
intend to pass the LinkSeq!(Apple) into a function
Hi All,
can I cast a LinkSeq from inherited type to base type?
code --
class Fruit {}
class Apple: Fruit {}
auto apples = new LinkSeq!(Apple);
apples.append(new Apple);
assert(apples !is null);
assert(apples.length == 1);
torhu wrote:
>
> If you mean short-circuit evalutation, I'm pretty sure that's always
> what the compiler does.
Thanks. Somebody posted this link:
http://digitalmars.com/d/1.0/expression.html#OrOrExpression
grauzone wrote:
> mport tango.io.Stdout;
>
> void main() {
>
> int v = 55;
> int *pv = &v;
>
> //pv (an int pointer) can be exchanged with v (an int),
> //and it still works
> auto i = pv;
>
> alias typeof(i) T;
> static if (is(T T2 : T2*)) {
> T2 i2 = *i;
> Stdout.formatln("{}", i2);
> } else
>
> if (isNull(foo) ||
> isNull(foo.getBar) ||
> isNull(foo.getBar.getBar2)
> {
> return false;
> }
Update: If minimal evaluation is not always enabled, and foo.getBar is NULL.
I will get a segfault when evaluating foo.getBar.getBar2.
Hi All,
Is minimal evaluation always enabled in D?
I want to write a function IsNull(), so that I can check the precondition as
follows:
if (isNull(foo) ||
isNull(foo.getBar) ||
isNull(foo.getBar.getBar2)
{
return false;
}
// normal code goes here
If an argument is null,
grauzone wrote:
>
> Check if the variable is a pointer, and if yes, dereference it:
>
> alias typeof(i) T;
> static if (is(T T2 : T2*)) {
> T2 i2 = *i;
> Format.convert("{}", i2);
> } else {
> Format.convert("{}", i);
> }
Hi again,
I cannot compile this code
Hi All,
tango.text.convert.Format provides a nice function to convert anything
to string.
It works perfect except the argument is a pointer type.
It will print the address of a pointer instead of its value
For instance:
int* i = new int;
*i = 10;
Format.conver
Hi All,
When I was trying to learn how char-array works, I found something
unexpected.
-- code --
module string_test;
void main()
{
// test 1
assert(null == "", "null is empty"); // No segfault
// test 2
char[] test; // test = null;
Hi All,
previously I saw an article about how to dump an object with all properties.
-code---
void log(T)(T obj) {
static if (is(T == struct) || is(T == class)){
writef("{");
foreach(i,_;obj.tupleof) {
writefln("%s : %s,", obj.tupleof[i].stri
Hi All,
We are redesigning a system (previously was written in C) using D.
We use Boundary-Controll-Entity-Pattern.
To wrap db table to entities is a very time consuming work.
Is there any framework or tips for multi-tier applications in D?
--Qian
Steven Schveighoffer wrote:
TimeStamp.iso8601(..) does not call the parse() function.
The bug was in parseInt. Please try it.
It worth a try.
I have added too many ".dup" in my code.
I will confirm this ASAP.
Thanks for your information ^^)
--
Xu, Qian (stanleyxu)
http://stanleyxu2005.
Steven Schveighoffer wrote:
>
> Coincidentally, someone else discovered a buffer-overrun bug in
> tango.text.convert.TimeStamp, see
> http://www.dsource.org/projects/tango/forums/topic/704
>
> Please try downloading the latest trunk code and see if your code still
> fails.
>
> You should not hav
Finally I have added timestring.dup in constructor, the problem does not
appear any more.
Oh god. I have to add ".dup" at the end of every string to avoid potential
program errors. This is so incredible
Best regards
Qian Xu
grauzone wrote:
Brian wrote:
On Sat, 21 Mar 2009 15:44:41 +0100, grauzone wrote:
I'm using dsss (with dmd under Linux) to compile my project, and
build/compile times are reaching unacceptable highs.
out of curiosity, how much code do you actually have? im using D for
something with ~12,000
grauzone wrote:
In my case, this practically always causes linker errors. Of course I
don't know why.
You could change the order of object files by linking.
if you have -> gdmd bbb.o aaa.o ccc.o -o binrary (-L. -l)
change to -> gdmd aaa.o bbb.o ccc.o -o binrary (-L. -l)
o
The problem has been solved.
There is a wonderfull function in Tango.
import tango.text.convert.Format;
class Foo {
// attributes go here...
public char[] toString() {
return Format.convert(" {} .. {} ..", attr1, attr2, attr3);
}
}
-
Daniel Keep wrote:
>
> to!(char[]) should call toString. to!(T) should support all atomic
> types, strings, structs and classes.
>
There is one problem: I have to check, whether a pointer is NULL.
If it is NULL, I should return "NULL", otherwise I should call to!(char[]
(*my_pointer_var)
I wa
S(bool val)
{
return to!(char[])(val);
}
--- my current version -----
Best regards
--Qian Xu
Frank Benoit wrote:
Qian Xu schrieb:
--- code 2 (current solution) --
public test(MyObj obj)
{
if (obj !is null &&
obj.getObj2 !is null &&
obj.getObj2.getObj3 !is null)
{
obj.getO
Hi All,
again to the topic "Segfault (NullPointerException) in Linux"
Is it really impossible to catch NullPointerException (segfault) using
try-catch-statement in Linux?
I can use signal handler to catch it at system level. But my program will
stop. If it can be captured inside the program. My
Jarrett Billingsley wrote:
> On Thu, Mar 5, 2009 at 3:17 AM, Qian Xu
> wrote:
>
>> this(char[] s, int flag) {
>> if (flag == 1)
>> {
>> this(1);
>> return;
>> }
>> else if (flag == 2)
>> {
>> this("hello");
>> retur
--
The warning is: "statement is not reachable"
If I use switch-case-statment, I can see even an error message:
"constructor calls not allowed in loops or after labels"
So, is my design incorrect, or is the compiler too strict?
--Qian Xu
ks with another SaxParser
--Qian Xu
BCS wrote:
Hello downs,
BCS:
you can have a posix signal handler throw an exception (I have done
it and had it work) but I have no idea if it is supported.
In my experience, that works exactly once.
That would match with what I needed: poor man's stack tracing
int EveryFunction()
{
scop
Hi All (again),
I got the following error message when my program is going to be linked:
error ---
default/common/configuration/Configuration_1.o:(.data+0x98): undefined
reference to `_D5tango4text3xml9SaxParser12_ModuleInfoZ'
-
Lutger wrote:
s[4] means the fifth element of s[]
s[0..4] is a slice from the first to the fifth, but not including the fifth
element. The last element in a slice is always one past the end of that
slice.
Thank you both.
I have to do math in mind in order to keep my code correct ;-)
IMO,
BCS wrote:
Hello Qian,
Hi All,
is it possible to see the reference counting of a char[]?
Almost certainly no. D Uses a mark-and-sweep GC not a ref counting one,
so there isn't a reference count.
sorry to have heard about that.
I am now suffering from debugging D programs in linux (ope
Hi,
I am confusing with getting sub-string of a char[].
- code -
module main;
import tango.io.Console;
import tango.text.convert.Integer;
void main()
{
char[] s = "ABCDE"; // 5 chars
int len = s.length;
Cout("s='" ~ s ~ "', length="
3 || text.attributeName[*q])
-
The assert will be broken 1-2 times, when I run a same test 1000 times.
So I want to know about the inside world of D-Compiler.
Best regards
--Qian Xu
UPDATE: I am using gdc compiler in Linux
Hi All,
Is there any way to keep program alive, when an AV takes place?
-- demo ---
module NullPointerExceptionTest;
class Foo {
void bar() {}
}
void main() {
Foo foo; // foo is still NULL
try {
foo.bar(); // A NullPointerException will be thrown
}
catc
Hi All,
Is there any tools to check dependency of d projects?
I want to remove all unnecessary imports, to make the build process more
faster :-)
Best regards
--Qian
grauzone wrote:
>
> Conclusion: == is absolutely useless in your case. Use something else.
But you have to write much more, just like my test(..) function does
--Qian Xu
b); // av error
}
If object at the left side of the != is null, I will get an AV error
immediately.
If I want to compare two objects safely, I have to write my own test(..)
function.
But this is not nice.
Can someone explain, is this a design shortcoming of D-Compiler, or I am
wrong.
Best regards
--Qian Xu
Hello All,
how to get the implementer of an interface?
Here is an example:
-
interface intf_1 {}
class c_1 : intf_1 {}
class c_2 : c_1 {}
c_1 aaa = new c_1;
c_2 bbb = new c_2;
auto list = [cast(intf_1)(bbb), cast(intf_1)(aaa)];
foreach
Frits van Bommel wrote:
> Qian Xu wrote:
>> Hi All,
>>
>> can D check, whether a class A an Interface B supports?
>>
>> like:
>>
>> if (supports(class_A, intf_B))
>
> if (is(class_A : intf_B))
> tests if 'class_A' is impli
Qian Xu wrote:
> Hi All,
>
> can D check, whether a class A an Interface B supports?
>
> like:
>
> if (supports(class_A, intf_B))
> {
> cast(intf_B) (class_A).hello();
> }
>
> --Qian
what I have found is:
if (is(class_A == intf_B))
Hi All,
can D check, whether a class A an Interface B supports?
like:
if (supports(class_A, intf_B))
{
cast(intf_B) (class_A).hello();
}
--Qian
Denis Koroskin wrote:
> ...
>
> For example, let's modify CSTR and see what happens:
> CSTR[0] = 'J'; // now it is "Jello"
>
> printing e.str and e2.str gives us the following output:
> Jello
> Jello
>
> ...
Hi again,
but there is one thing, I do not understand.
CSTR is a constant. But with "
Denis Koroskin wrote:
7 - e2.str = "world";
State: CLIST : ["333", "444"];
e : list = ["333", "444"]; str = "hello";
e2: list = ["333", "444"]; str = "world";
Hope it helps.
Thanks for your nice answer. You made my day ;-)
--
Xu, Qian (stanleyxu)
http://stanleyxu2005.b
Hi All,
I have accidentally written a buggy class.
Briefly described as follows:
1. The class contains a list of string
2. The list of string is assigned to a constant in constructor
3. Try to change the value of the list
4. Create another class by repeating step 1-3 again
5. Add both of th
Denis Koroskin wrote:
>
> The "Hello, World!" string is not allowed to be modified, because it could
> be shared throughot the project and will be most probably put in a
> read-only memory causing segfault at modification.
>
> But it you need to have a modified version of this this, you create it
When shall I use some_var.dup and when not?
Is there any guidlines?
--Qian
Stewart Gordon wrote:
> My library stores all times in UTC, but allows them to be manipulated in
> any time zone. But it doesn't yet support daylight saving time
> adjustments. I haven't quite worked out how best to do this. (It
> initialises the working time zone to the user's current time zone
BTW: Is there any Date.Format("-mm-dd") function?
Hi All,
I am fighting with date time conversion and have a problem right now:
I want to convert a local timestamp to UTC timestamp.
So I have to get the time zone information.
However in some countries (ie. German, US), the offset is not constant,
because of daylight saving issue.
Is there any "h
BCS wrote:
Reply to Qian,
Hi All,
I am new to D community. I have some problems with TimeOfDay struct.
I have defined a class:
class Test
{
TimeOfDay* getTime() {
return a_valid_timeofday_pointer;
}
Could you expand on this function?
BCS wrote:
Reply to Qian,
Hi All,
I am new to D community. I have some problems with TimeOfDay struct.
I have defined a class:
class Test
{
TimeOfDay* getTime() {
return a_valid_timeofday_pointer;
}
Could you expand on this function?
Hi All,
I am new to D community. I have some problems with TimeOfDay struct.
I have defined a class:
class Test
{
TimeOfDay* getTime() {
return a_valid_timeofday_pointer;
}
void setTime(TimeOfDay* value) {
setVa
70 matches
Mail list logo