D - finding the class of an object
- James Gilbert <jgrg sanger.ac.uk> Sep 11 2001
- "Walter" <walter digitalmars.com> Sep 11 2001
- James Gilbert <jgrg sanger.ac.uk> Sep 12 2001
- Erik Rounds <erikr aatrix.com> Sep 12 2001
- Erik Rounds <erikr aatrix.com> Sep 12 2001
- James Gilbert <jgrg sanger.ac.uk> Sep 13 2001
- Erik Rounds <erikr aatrix.com> Sep 13 2001
- "Walter" <walter digitalmars.com> Sep 18 2001
- "Sean L. Palmer" <spalmer iname.com> Oct 23 2001
- "Walter" <walter digitalmars.com> Nov 23 2001
- "Ben Cohen" <bc skygate.co.uk> Sep 12 2001
- James Gilbert <jgrg sanger.ac.uk> Sep 13 2001
- "Ben Cohen" <bc skygate.co.uk> Sep 13 2001
- Russell Bornschlegel <kaleja estarcion.com> Sep 13 2001
- "Walter" <walter digitalmars.com> Sep 20 2001
- Charles Hixson <charleshixsn earthlink.net> Sep 20 2001
- a <a b.c> Sep 20 2001
- John Fletcher <J.P.Fletcher aston.ac.uk> Sep 21 2001
- "Walter" <walter digitalmars.com> Oct 10 2001
- "Rajiv Bhagwat" <dataflow vsnl.com> Oct 10 2001
Is there a way to find out which class an object belongs
to? If not, how about obj.class?
BTW, I think there is a buglet in the doc:
D does not have a Java style instanceof operator,
because the cast operator performs the same function:
Java:
if (a instanceof B)
D:
if ((B) a)
should be: if (cast(B) a)
Sep 11 2001
1) Yes, there will be a .class or some such. -Walter 2) I am undecided if the cast syntax should be like C or like cast(B) a. "James Gilbert" <jgrg sanger.ac.uk> wrote in message news:3B9DF36F.81584272 sanger.ac.uk...Is there a way to find out which class an object belongs to? If not, how about obj.class? BTW, I think there is a buglet in the doc: D does not have a Java style instanceof operator, because the cast operator performs the same function: Java: if (a instanceof B) D: if ((B) a) should be: if (cast(B) a)
Sep 11 2001
Walter wrote:1) Yes, there will be a .class or some such. -Walter
Great.2) I am undecided if the cast syntax should be like C or like cast(B) a.
I like the explicit "cast". I thought you were sold on it from the doc, where you say it removes context- sensitive parsing of "()". James"James Gilbert" <jgrg sanger.ac.uk> wrote in message news:3B9DF36F.81584272 sanger.ac.uk...Is there a way to find out which class an object belongs to? If not, how about obj.class? BTW, I think there is a buglet in the doc: D does not have a Java style instanceof operator, because the cast operator performs the same function: Java: if (a instanceof B) D: if ((B) a) should be: if (cast(B) a)
Sep 12 2001
type? Like Foo'class or Array'length. This would provide the distinction between class members and primitive type information. There could be a Foo.class without there being any confusion. Just thought I'd offer my two cents. Walter wrote:1) Yes, there will be a .class or some such. -Walter 2) I am undecided if the cast syntax should be like C or like cast(B) a. "James Gilbert" <jgrg sanger.ac.uk> wrote in message news:3B9DF36F.81584272 sanger.ac.uk...Is there a way to find out which class an object belongs to? If not, how about obj.class? BTW, I think there is a buglet in the doc: D does not have a Java style instanceof operator, because the cast operator performs the same function: Java: if (a instanceof B) D: if ((B) a) should be: if (cast(B) a)
Sep 12 2001
oops, sorry I guess I lost the first line. Here it is again: Why don't we use a tick operator ' to retrieve data from a primitive type? Like Foo'class or Array'length. This would provide the distinction between class members and primitive type information. There could be a Foo.class without there being any confusion. Just thought I'd offer my two cents. Erik Rounds wrote:type? Like Foo'class or Array'length. This would provide the distinction between class members and primitive type information. There could be a Foo.class without there being any confusion. Just thought I'd offer my two cents. Walter wrote:1) Yes, there will be a .class or some such. -Walter 2) I am undecided if the cast syntax should be like C or like cast(B) a. "James Gilbert" <jgrg sanger.ac.uk> wrote in message news:3B9DF36F.81584272 sanger.ac.uk...Is there a way to find out which class an object belongs to? If not, how about obj.class? BTW, I think there is a buglet in the doc: D does not have a Java style instanceof operator, because the cast operator performs the same function: Java: if (a instanceof B) D: if ((B) a) should be: if (cast(B) a)
Sep 12 2001
Erik Rounds wrote:oops, sorry I guess I lost the first line. Here it is again: Why don't we use a tick operator ' to retrieve data from a primitive type? Like Foo'class or Array'length. This would provide the distinction between class members and primitive type information. There could be a Foo.class without there being any confusion. Just thought I'd offer my two cents.
My $0.02 is that the tick operator plays merry hell with syntax highlighting in editors. James
Sep 13 2001
I'm sure that editors can be made to accomidate. Anyway, the point is having an operator which won't be confused with the . or -> operator. I know that the -> operator won't be used in D, but I think we should avoid using it in order to avoid confusing C++ programmers new to the language. James Gilbert wrote:Erik Rounds wrote:oops, sorry I guess I lost the first line. Here it is again: Why don't we use a tick operator ' to retrieve data from a primitive type? Like Foo'class or Array'length. This would provide the distinction between class members and primitive type information. There could be a Foo.class without there being any confusion. Just thought I'd offer my two cents.
My $0.02 is that the tick operator plays merry hell with syntax highlighting in editors. James
Sep 13 2001
James Gilbert wrote in message <3BA08D12.894CA875 sanger.ac.uk>...Erik Rounds wrote:oops, sorry I guess I lost the first line. Here it is again: Why don't we use a tick operator ' to retrieve data from a primitive type? Like Foo'class or Array'length. This would provide the
between class members and primitive type information. There could be a Foo.class without there being any confusion. Just thought I'd offer my
cents.
My $0.02 is that the tick operator plays merry hell with syntax highlighting in editors.
The ' operator would make it impossible to tokenize the language separately from syntax analysis. Perhaps the : would work better.
Sep 18 2001
Or you could use # Sean "Walter" <walter digitalmars.com> wrote in message news:9o99bv$a8v$1 digitaldaemon.com...James Gilbert wrote in message <3BA08D12.894CA875 sanger.ac.uk>...Erik Rounds wrote:oops, sorry I guess I lost the first line. Here it is again: Why don't we use a tick operator ' to retrieve data from a primitive type? Like Foo'class or Array'length. This would provide the
between class members and primitive type information. There could be a Foo.class without there being any confusion. Just thought I'd offer my
cents.
My $0.02 is that the tick operator plays merry hell with syntax highlighting in editors.
The ' operator would make it impossible to tokenize the language
from syntax analysis. Perhaps the : would work better.
Oct 23 2001
Yes, # would work. "Sean L. Palmer" <spalmer iname.com> wrote in message news:9r3dsr$a27$1 digitaldaemon.com...Or you could use # Sean "Walter" <walter digitalmars.com> wrote in message news:9o99bv$a8v$1 digitaldaemon.com...James Gilbert wrote in message <3BA08D12.894CA875 sanger.ac.uk>...Erik Rounds wrote:oops, sorry I guess I lost the first line. Here it is again: Why don't we use a tick operator ' to retrieve data from a primitive type? Like Foo'class or Array'length. This would provide the
between class members and primitive type information. There could be
Foo.class without there being any confusion. Just thought I'd offer
twocents.
My $0.02 is that the tick operator plays merry hell with syntax highlighting in editors.
The ' operator would make it impossible to tokenize the language
from syntax analysis. Perhaps the : would work better.
Nov 23 2001
In article <3B9DF36F.81584272 sanger.ac.uk>, "James Gilbert" <jgrg sanger.ac.uk> wrote:Is there a way to find out which class an object belongs to? If not, how about obj.class? BTW, I think there is a buglet in the doc: D does not have a Java style instanceof operator, because the cast operator performs the same function: Java: if (a instanceof B) D: if ((B) a) should be: if (cast(B) a)
Doesn't this have an ambiguity if B is a boolean type variable (or int if there is no boolean)? I.e., we could be asking "Is a of type B?" or "Is a true when cast to type B?" Incidentally, I noted elsewhere that C's -> notation might not be needed in D. If you don't mind using it for something else, then casts would be a possible use: foo->long You could even introduce a new operator, =>, for instanceof so that the following are different: if (a->int)... if (a=>int)... (Properties would be another possible use: myvar->size)
Sep 12 2001
Ben Cohen wrote:In article <3B9DF36F.81584272 sanger.ac.uk>, "James Gilbert" <jgrg sanger.ac.uk> wrote:Is there a way to find out which class an object belongs to? If not, how about obj.class? BTW, I think there is a buglet in the doc: D does not have a Java style instanceof operator, because the cast operator performs the same function: Java: if (a instanceof B) D: if ((B) a) should be: if (cast(B) a)
Doesn't this have an ambiguity if B is a boolean type variable (or int if there is no boolean)? I.e., we could be asking "Is a of type B?" or "Is a true when cast to type B?"
Good point. I was also thinking that an "instanceof" operator might be able to do less work than a cast to get you the answer. I suppose the compiler could work out that the cast was being used in boolean context, but this would be surpising to the programmer, and deviate from Walter's idea of a context-free compiler.Incidentally, I noted elsewhere that C's -> notation might not be needed in D. If you don't mind using it for something else, then casts would be a possible use: foo->long You could even introduce a new operator, =>, for instanceof so that the following are different: if (a->int)... if (a=>int)... (Properties would be another possible use: myvar->size)
I would try to avoid operators that are used for different things in similar languages!
Sep 13 2001
In article <3BA08FBC.158C9162 sanger.ac.uk>, "James Gilbert" <jgrg sanger.ac.uk> wrote:Incidentally, I noted elsewhere that C's -> notation might not be needed in D. If you don't mind using it for something else, then casts would be a possible use: foo->long
I would try to avoid operators that are used for different things in similar languages!
That is sensible ... but a pity to leave the notation unused!
Sep 13 2001
Ben Cohen wrote:In article <3BA08FBC.158C9162 sanger.ac.uk>, "James Gilbert" <jgrg sanger.ac.uk> wrote:Incidentally, I noted elsewhere that C's -> notation might not be needed in D. If you don't mind using it for something else, then casts would be a possible use: foo->long
I would try to avoid operators that are used for different things in similar languages!
That is sensible ... but a pity to leave the notation unused!
Perhaps if the parser sees a "->" token, it could open a web browser to a page titled "D for C Programmers". -RB
Sep 13 2001
Russell Bornschlegel wrote in message <3BA0E8CF.5BFDE051 estarcion.com>...Perhaps if the parser sees a "->" token, it could open a web browser to a
titled "D for C Programmers".
I'm still looking for a use for the error message: "fix card deck and resubmit job"
Sep 20 2001
Walter wrote:... I'm still looking for a use for the error message: "fix card deck and resubmit job"
You could have a sample that implements a deck editor for FreeCell.
Sep 20 2001
Walter wrote:Russell Bornschlegel wrote in message <3BA0E8CF.5BFDE051 estarcion.com>...Perhaps if the parser sees a "->" token, it could open a web browser to a
titled "D for C Programmers".
I'm still looking for a use for the error message: "fix card deck and resubmit job"
Display it if any variable named foo, bar, baz or foobar is used incorrectly. Dan
Sep 20 2001
Walter wrote:Russell Bornschlegel wrote in message <3BA0E8CF.5BFDE051 estarcion.com>...Perhaps if the parser sees a "->" token, it could open a web browser to a
titled "D for C Programmers".
I'm still looking for a use for the error message: "fix card deck and resubmit job"
I once had a job fail because the following job had been put onto the card reader upside down, and became data for my program. FORTRAN of course, about 1970. John
Sep 21 2001
John Fletcher wrote in message <3BAAFEB8.3E001B7 aston.ac.uk>...Walter wrote:Russell Bornschlegel wrote in message
Perhaps if the parser sees a "->" token, it could open a web browser to
pagetitled "D for C Programmers".
I'm still looking for a use for the error message: "fix card deck and resubmit job"
I once had a job fail because the following job had been put onto the card reader upside down, and became data for my program. FORTRAN of course,
1970.
It's nice to know there are some people who have been programming longer than me <g>. And yes, my first programs were on punch cards.
Oct 10 2001
Walter <walter digitalmars.com> wrote in message news:9q14m0$12ed$1 digitaldaemon.com...John Fletcher wrote in message <3BAAFEB8.3E001B7 aston.ac.uk>...Walter wrote:Russell Bornschlegel wrote in message
Perhaps if the parser sees a "->" token, it could open a web browser
apagetitled "D for C Programmers".
I'm still looking for a use for the error message: "fix card deck and resubmit job"
I once had a job fail because the following job had been put onto the
reader upside down, and became data for my program. FORTRAN of course,
1970.
It's nice to know there are some people who have been programming longer than me <g>. And yes, my first programs were on punch cards.
I used cards in 1975, but encountered a Russian computer (Model: Minsk-2) with very hard pushbuttons in '79. These buttons would light lamps and frequently were stuck. How about some use for the message: 'Push harder, then it might work!' Ps: Not to be behind, next to the Russian m/c was a Hewlett-Packard machine, using Buttons and Lights: HP-21! The buttons here were a lot smoother and had lights behind them, as the console was very small.
Oct 10 2001









James Gilbert <jgrg sanger.ac.uk> 