D - finding the class of an object
- James Gilbert (10/10) Sep 11 2001 Is there a way to find out which class an object belongs
- Walter (4/14) Sep 11 2001 1) Yes, there will be a .class or some such. -Walter
- James Gilbert (6/27) Sep 12 2001 I like the explicit "cast". I thought you were sold
- Erik Rounds (5/25) Sep 12 2001 type? Like Foo'class or Array'length. This would provide the distincti...
- Erik Rounds (7/34) Sep 12 2001 oops, sorry I guess I lost the first line. Here it is again:
- James Gilbert (4/12) Sep 13 2001 My $0.02 is that the tick operator plays merry hell
- Erik Rounds (5/17) Sep 13 2001 I'm sure that editors can be made to accomidate. Anyway, the point is h...
- Walter (5/16) Sep 18 2001 two
- Sean L. Palmer (5/22) Oct 23 2001 Or you could use #
- Walter (5/29) Nov 23 2001 Yes, # would work.
- Ben Cohen (14/28) Sep 12 2001 Doesn't this have an ambiguity if B is a boolean type variable (or int i...
- James Gilbert (11/46) Sep 13 2001 Good point.
- Ben Cohen (4/12) Sep 13 2001 ...
- Russell Bornschlegel (4/19) Sep 13 2001 Perhaps if the parser sees a "->" token, it could open a web browser to ...
- Walter (4/6) Sep 20 2001 I'm still looking for a use for the error message:
- Charles Hixson (2/7) Sep 20 2001 You could have a sample that implements a deck editor for FreeCell.
- a (4/13) Sep 20 2001 Display it if any variable named foo, bar, baz or foobar is used
- John Fletcher (5/11) Sep 21 2001 I once had a job fail because the following job had been put onto the ca...
- Walter (6/18) Oct 10 2001 a
- Rajiv Bhagwat (11/30) Oct 10 2001 to
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. -WalterGreat.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:distinctionoops, 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 thetwobetween class members and primitive type information. There could be a Foo.class without there being any confusion. Just thought I'd offer myThe ' operator would make it impossible to tokenize the language separately from syntax analysis. Perhaps the : would work better.cents.My $0.02 is that the tick operator plays merry hell with syntax highlighting in editors.
Sep 18 2001
Sean "Walter" <walter digitalmars.com> wrote in message news:9o99bv$a8v$1 digitaldaemon.com...James Gilbert wrote in message <3BA08D12.894CA875 sanger.ac.uk>...separatelyErik Rounds wrote:distinctionoops, 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 thetwobetween class members and primitive type information. There could be a Foo.class without there being any confusion. Just thought I'd offer myThe ' operator would make it impossible to tokenize the languagecents.My $0.02 is that the tick operator plays merry hell with syntax highlighting in editors.from syntax analysis. Perhaps the : would work better.
Oct 23 2001
"Sean L. Palmer" <spalmer iname.com> wrote in message news:9r3dsr$a27$1 digitaldaemon.com...Sean "Walter" <walter digitalmars.com> wrote in message news:9o99bv$a8v$1 digitaldaemon.com...aJames Gilbert wrote in message <3BA08D12.894CA875 sanger.ac.uk>...Erik Rounds wrote:distinctionoops, 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 thebetween class members and primitive type information. There could bemyFoo.class without there being any confusion. Just thought I'd offertwoseparatelyThe ' operator would make it impossible to tokenize the languagecents.My $0.02 is that the tick operator plays merry hell with syntax highlighting in editors.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: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.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)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->longI 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:Perhaps if the parser sees a "->" token, it could open a web browser to a page titled "D for C Programmers". -RB...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->longI 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
Russell Bornschlegel wrote in message <3BA0E8CF.5BFDE051 estarcion.com>...Perhaps if the parser sees a "->" token, it could open a web browser to apagetitled "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>...Display it if any variable named foo, bar, baz or foobar is used incorrectly. DanPerhaps if the parser sees a "->" token, it could open a web browser to apagetitled "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:Russell Bornschlegel wrote in message <3BA0E8CF.5BFDE051 estarcion.com>...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. JohnPerhaps if the parser sees a "->" token, it could open a web browser to apagetitled "D for C Programmers".I'm still looking for a use for the error message: "fix card deck and resubmit job"
Sep 21 2001
John Fletcher wrote in message <3BAAFEB8.3E001B7 aston.ac.uk>...Walter wrote:<3BA0E8CF.5BFDE051 estarcion.com>...Russell Bornschlegel wrote in messageaPerhaps if the parser sees a "->" token, it could open a web browser toaboutpageI 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,titled "D for C Programmers".I'm still looking for a use for the error message: "fix card deck and resubmit job"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>...toWalter wrote:<3BA0E8CF.5BFDE051 estarcion.com>...Russell Bornschlegel wrote in messagePerhaps if the parser sees a "->" token, it could open a web browseracardpageI once had a job fail because the following job had been put onto thetitled "D for C Programmers".I'm still looking for a use for the error message: "fix card deck and resubmit job"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.reader upside down, and became data for my program. FORTRAN of course,about1970.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