Post #58,697
10/23/02 6:11:31 AM
10/23/02 7:21:44 AM
|
No, wait, I need more context.
Thats a little weird. Can you elaborate? How do you end up using that?
Honest, I thought I'd seen it all with the template meta program nonsense (you declare a template in terms of another template which produces what amounts to recursive expansion that you halt at some level by declaring a template specializtion).
That example is something like (my syntax is rusty):
template <int i> class Factorial { public operator int() { return i * Factorial<i-1>; } } with specialization for
class Factorial<0> { public operator int() { return 1; } }
Which does all its calculation at compile time.
-edit fixed syntax error
I am out of the country for the duration of the Bush administration. Please leave a message and I'll get back to you when democracy returns.
|
Post #58,765
10/23/02 10:05:52 AM
|
Wow!
Compile-time recursion! I'll be damned.
The need for this arose from unit testing a template class. I have a scheduler class, and it takes the type of thing it will schedule as its template argument. So, naturally, I wanted to write a unit test class for that scheduler. One of the things that unit test needs is a sample schedulable entity, something that would record when it gets attention so that I can check the accuracy of scheduling at the end of test.
So far so good. However, the scheduled thing in my case needed a back lilnk to scheduler. Don't ask why, it's not really important. As long as I only had one type of scheduler, things were fine. But then I expanded the code to have 2 differnt types of scheduler (will have 3 in the future). And I wanted to reuse unit tests. But now we have a problem. The scheduled entity needed to be told the class of the scheduler (for the back pointer). And the scheduler needs to be told the class of scheduled entity. Circular dependencies.
Then it struck me that if I could pass scheduler template name (as opposed to an instanciation of template) to the scheduled entity, I would be OK. The scheduled entity will instantiate the template with itself, and, lo and behold - dependency solved. So I took a look at C++ standard, and sure enough, a template argument can take a form of not only
class X
but also
template <class P> class X
And I used it. See the code at the beginning of the thread as to how.
--
We have only 2 things to worry about: That things will never get back to normal, and that they already have.
|
Post #58,772
10/23/02 10:30:12 AM
10/23/02 10:30:54 AM
|
Grammar police
Then it struck me that if I could pass scheduler template name (as opposed to an instanciation of template) I believe you mean an instance. This strikes me as being similar to someone saying they "administrate" a box, rather than "administer" it. [Edit was typo police in the subject]
=== Microsoft offers them the one thing most business people will pay any price for - the ability to say "we had no choice - everyone's doing it that way." -- [link|http://z.iwethey.org/forums/render/content/show?contentid=38978|Andrew Grygus]
Edited by drewk
Oct. 23, 2002, 10:30:54 AM EDT
|
Post #58,778
10/23/02 10:38:00 AM
|
No
Computerese, esp C++ese, really has these abominable words. However it's spelled "instantiation".
-drl
|
Post #58,811
10/23/02 11:38:00 AM
|
Spelling police
Classes have instances. I think (not hunderd percent sure) that templates have instantiations (can't have a partial instance, but a partial instantiation is possible). The spelling was indeed wrong (thanks, deS).
--
We have only 2 things to worry about: That things will never get back to normal, and that they already have.
|
Post #58,812
10/23/02 11:40:55 AM
|
Arrrgh!
That's just so damn wrong! Leave it to people writing their own new "language" to decide to modify existing ones while they're at it.
=== Microsoft offers them the one thing most business people will pay any price for - the ability to say "we had no choice - everyone's doing it that way." -- [link|http://z.iwethey.org/forums/render/content/show?contentid=38978|Andrew Grygus]
|
Post #58,813
10/23/02 11:44:12 AM
|
Instantiation has been in use for a long time...
[link|http://www.m-w.com/cgi-bin/dictionary?book=Dictionary&va=instantiation|"instantiation"]
One of the hallmarks of the English language is its malleability. Deal with it. ;-)
Or would you prefer the French Language Inquisition to set up shop here as well?
Regards,
-scott anderson
"Welcome to Rivendell, Mr. Anderson..."
|
Post #58,829
10/23/02 12:11:23 PM
|
Careful, keep this up and you'll be agreeing with ...
No, I can't type it out loud.
Anyway, I'm not saying language can't/shouldn't change, but in this case "instance" is most nearly the root of that group of words. "Instantiate" is a suffixed form, "instantiation" would be a multiply-suffixed form that is syntactically equivalent to the root. It's just bad grammar.
And furthermore ... you didn't just suggest that "people have been getting it wrong for a long time" is a valid defense of it, did you?
=== Microsoft offers them the one thing most business people will pay any price for - the ability to say "we had no choice - everyone's doing it that way." -- [link|http://z.iwethey.org/forums/render/content/show?contentid=38978|Andrew Grygus]
|
Post #58,831
10/23/02 12:15:22 PM
|
Re: Careful, keep this up and you'll be agreeing with ...
"People have been getting it wrong for a long time" is exactly how things change in languages.
Instance sounds static. Instantiation implies the act of instantiation as well. Subtle connotation difference, but it's there.
Regards,
-scott anderson
"Welcome to Rivendell, Mr. Anderson..."
|
Post #58,838
10/23/02 12:22:27 PM
|
Then I hereby nominate ... objectification
Object sounds static. Objectification implies the act of objectification as well. :-p
=== Microsoft offers them the one thing most business people will pay any price for - the ability to say "we had no choice - everyone's doing it that way." -- [link|http://z.iwethey.org/forums/render/content/show?contentid=38978|Andrew Grygus]
|
Post #58,841
10/23/02 12:24:56 PM
|
Re: Then I hereby nominate ... objectification
[link|http://www.m-w.com/cgi-bin/dictionary?book=Dictionary&va=objectification|"objectification"]
The act of objectifying something.
Date: circa 1837
This one is over 100 years older than instantiation. ;-) Thanks for playing, drive through.
Regards,
-scott anderson
"Welcome to Rivendell, Mr. Anderson..."
|
Post #58,843
10/23/02 12:27:28 PM
|
He meant "objectifaction"
defn: Making a rotten object (from "object putrefaction").
-drl
|
Post #58,844
10/23/02 12:29:04 PM
|
Re: He meant "objectifaction"
[link|http://www.m-w.com/cgi-bin/dictionary?book=Dictionary&va=objectifaction|"objectifaction"]
That one actually works as a joke. ;-)
Regards,
-scott anderson
"Welcome to Rivendell, Mr. Anderson..."
|
Post #58,863
10/23/02 1:31:13 PM
|
Not as a noun, though
You're using "instantiation" as a noun. Then "objectification" would have to be a noun also. As in, "The input to this function is an objectification."
Thank you for playing.
=== Microsoft offers them the one thing most business people will pay any price for - the ability to say "we had no choice - everyone's doing it that way." -- [link|http://z.iwethey.org/forums/render/content/show?contentid=38978|Andrew Grygus]
|
Post #58,884
10/23/02 2:21:20 PM
|
Objectification IS a noun, you knob.
Regards,
-scott anderson
"Welcome to Rivendell, Mr. Anderson..."
|
Post #58,888
10/23/02 2:43:50 PM
|
Umm, well, yeah, but ... uhhh
CrrrrrrrAP!
I'm even forced to admit that it's possible "instantiation" might have been correct in the first instance.
=== Microsoft offers them the one thing most business people will pay any price for - the ability to say "we had no choice - everyone's doing it that way." -- [link|http://z.iwethey.org/forums/render/content/show?contentid=38978|Andrew Grygus]
|
Post #58,889
10/23/02 2:44:36 PM
|
Welll...
WTF did you think I linked to Merriam Webster for...?
Regards,
-scott anderson
"Welcome to Rivendell, Mr. Anderson..."
|
Post #59,009
10/24/02 2:01:53 AM
|
You've been using that a lot lately.
"knob", that is. It sounds so British. Do you know where you picked it up from?
Wade
"Ah. One of the difficult questions."
|
Post #59,015
10/24/02 3:11:38 AM
|
Well I know where *I* got it from
Larry Wall. [link|http://interviews.slashdot.org/article.pl?sid=02/09/06/1343222&mode=thread&tid=145|Perl 6 will give you the big knob.]
Cheers, Ben
"Career politicians are inherently untrustworthy; if it spends its life buzzing around the outhouse, it\ufffds probably a fly." - [link|http://www.nationalinterest.org/issues/58/Mead.html|Walter Mead]
|
Post #59,032
10/24/02 7:54:05 AM
|
My (obvious) guess: Peter.
You know, [link|/forums/render/user?username=pwhysall|pwhysall].
(Wow -- these WeirdCode thingies seem to be *working*! :-)
Christian R. Conrad Microsoft is a true reflection of Bill Gates' personality - the sleaziest, most unethical, ugliest little rat's ass the world has seen unto this time. -- [link|http://z.iwethey.org/forums/render/content/show?contentid=42971|Andrew Grygus]
|
Post #59,039
10/24/02 9:07:48 AM
|
Dunno.
Just one of those things I picked up somewhere.
I tend to use an eclectic collection of phrases, given how many shady characters from around the world I associate with. ;-)
Regards,
-scott anderson
"Welcome to Rivendell, Mr. Anderson..."
|
Post #58,821
10/23/02 11:59:02 AM
|
I'm not saying its good.
But rather than templates - why don't you just provide an abstract class for the back pointer and use that. Why must it be the specific implementation class?
I am out of the country for the duration of the Bush administration. Please leave a message and I'll get back to you when democracy returns.
|
Post #58,876
10/23/02 1:57:40 PM
|
Was trying to avoid virtual functions
This stuff is potentially in a tight loop.
--
We have only 2 things to worry about: That things will never get back to normal, and that they already have.
|
Post #58,877
10/23/02 2:01:17 PM
|
ROFL - "This prog might actually do something needing speed"
-drl
|
Post #59,020
10/24/02 4:22:55 AM
|
Write the program you want
then optimize it.
Not the other way around.
The number of people who need to write performance critical code is at least 3 orders of magnitude smaller than the people who think they need to write performance critical code.
I am out of the country for the duration of the Bush administration. Please leave a message and I'll get back to you when democracy returns.
|
Post #59,043
10/24/02 9:31:49 AM
|
I know, I know.
I have always heard that theory that templates are as powerful for generic programming as virtual functions. I decided to test that statement. In the end, templates worked out just fine, the code is no less elegant than it would be if I used an interface. And the code is not _really_ in a tight loop at the moment. In my defense I can only say that the code that's being replaced with the scheduler used to take 80% of CPU time, so I wanted the replacement to be very, very tight. May be tighter than it needs to be.
--
We have only 2 things to worry about: That things will never get back to normal, and that they already have.
|