Pages: « 1 2 3 4 5 6 »
  Print  
Author Topic: Happy New Year  (Read 10854 times)
Offline (Male) RetroX
Reply #30 Posted on: January 10, 2010, 04:19:17 PM

Master of all things Linux
Contributor
Location: US
Joined: Apr 2008
Posts: 1055
MSN Messenger - classixretrox@gmail.com
View Profile Email
By the way, Josh, make sure that your handler doesn't see template<template<>> as the same thing as template<template<> >, although, I'm pretty sure that you've already handled that.
Logged
My Box: Phenom II 3.4GHz X4 | ASUS ATI RadeonHD 5770, 1GB GDDR5 RAM | 1x4GB DDR3 SRAM | Arch Linux, x86_64 (Cube) / Windows 7 x64 (Blob)
Quote from: Fede-lasse
Why do all the pro-Microsoft people have troll avatars? :(
Offline (Unknown gender) score_under
Reply #31 Posted on: January 12, 2010, 12:29:20 PM

Member
Joined: Aug 2008
Posts: 308

View Profile
template<template<>>
template<template<> >
Are those actually different? Whitespace is not supposed to matter very much in C-based languages.
Logged
Offline (Unknown gender) luiscubal
Reply #32 Posted on: January 12, 2010, 12:43:19 PM
Member
Joined: Jun 2009
Posts: 452

View Profile Email
Yes, they are. Because whitespace DOES matter in C.

== is not the same as = =.
And >> is an operator(bitwise shift), so it is forbidden in templates.
That is, it WAS forbidden until C++0x came.
Logged
Offline (Male) RetroX
Reply #33 Posted on: January 12, 2010, 04:03:30 PM

Master of all things Linux
Contributor
Location: US
Joined: Apr 2008
Posts: 1055
MSN Messenger - classixretrox@gmail.com
View Profile Email
template<template<>>
template<template<> >
Are those actually different? Whitespace is not supposed to matter very much in C-based languages.
>> is considered as an operator, so they must be separate.
Logged
My Box: Phenom II 3.4GHz X4 | ASUS ATI RadeonHD 5770, 1GB GDDR5 RAM | 1x4GB DDR3 SRAM | Arch Linux, x86_64 (Cube) / Windows 7 x64 (Blob)
Quote from: Fede-lasse
Why do all the pro-Microsoft people have troll avatars? :(
Offline (Unknown gender) score_under
Reply #34 Posted on: January 12, 2010, 05:56:42 PM

Member
Joined: Aug 2008
Posts: 308

View Profile
template<template<>>
template<template<> >
Are those actually different? Whitespace is not supposed to matter very much in C-based languages.
>> is considered as an operator, so they must be separate.
I see, *adds to list of reasons not to use C++*
Logged
Offline (Male) Rusky
Reply #35 Posted on: January 12, 2010, 09:16:06 PM

Resident Troll
Joined: Feb 2008
Posts: 955
MSN Messenger - rpjohnst@gmail.com
View Profile WWW Email
It just comes from the stupid idea to use <> for templates. Because the lexer finds the biggest token it can and >> is an operator, closing two template tags in a row causes problems. Other than that, this behavior for the lexer makes perfect sense- it parses "asdfasdf = 3" as asdfasdf, = and 3, rather than a, s, d, f, a, s, d, f, = and 3.
Logged
Offline (Unknown gender) score_under
Reply #36 Posted on: January 13, 2010, 01:02:11 PM

Member
Joined: Aug 2008
Posts: 308

View Profile
It just comes from the stupid idea to use <> for templates.
Exactly.

Quote
Because the lexer finds the biggest token it can and >> is an operator, closing two template tags in a row causes problems. Other than that, this behavior for the lexer makes perfect sense- it parses "asdfasdf = 3" as asdfasdf, = and 3, rather than a, s, d, f, a, s, d, f, = and 3.
And if it did that (string into array of chars, i.e. NOTHING :p ), there'd really be no point in it.
Logged
Offline (Male) RetroX
Reply #37 Posted on: January 13, 2010, 03:22:36 PM

Master of all things Linux
Contributor
Location: US
Joined: Apr 2008
Posts: 1055
MSN Messenger - classixretrox@gmail.com
View Profile Email
It just comes from the stupid idea to use <> for templates. Because the lexer finds the biggest token it can and >> is an operator, closing two template tags in a row causes problems. Other than that, this behavior for the lexer makes perfect sense- it parses "asdfasdf = 3" as asdfasdf, = and 3, rather than a, s, d, f, a, s, d, f, = and 3.
It does not make sense to be green without chlorophyll.
Logged
My Box: Phenom II 3.4GHz X4 | ASUS ATI RadeonHD 5770, 1GB GDDR5 RAM | 1x4GB DDR3 SRAM | Arch Linux, x86_64 (Cube) / Windows 7 x64 (Blob)
Quote from: Fede-lasse
Why do all the pro-Microsoft people have troll avatars? :(
Offline (Unknown gender) luiscubal
Reply #38 Posted on: January 13, 2010, 03:25:51 PM
Member
Joined: Jun 2009
Posts: 452

View Profile Email
D uses f!(1) instead of f<1> for templates.
C# and Java solve this problem making templates apply only to types, never numbers, so you won't ever write class X<3>>2>.
Logged
Offline (Male) RetroX
Reply #39 Posted on: January 13, 2010, 04:50:40 PM

Master of all things Linux
Contributor
Location: US
Joined: Apr 2008
Posts: 1055
MSN Messenger - classixretrox@gmail.com
View Profile Email
D uses f!(1) instead of f<1> for templates.
Good for D.

C# and Java solve this problem making templates apply only to types, never numbers, so you won't ever write class X<3>>2>.
Which is one of the reasons that C# and Java suck.  Number templates are extremely useful in some cases.
Logged
My Box: Phenom II 3.4GHz X4 | ASUS ATI RadeonHD 5770, 1GB GDDR5 RAM | 1x4GB DDR3 SRAM | Arch Linux, x86_64 (Cube) / Windows 7 x64 (Blob)
Quote from: Fede-lasse
Why do all the pro-Microsoft people have troll avatars? :(
Offline (Male) Josh @ Dreamland
Reply #40 Posted on: January 13, 2010, 10:28:32 PM

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2949

View Profile Email
Like fucking up my parser. Twice.
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Unknown gender) Micah
Reply #41 Posted on: January 14, 2010, 12:20:50 AM

Resident Troll
Joined: May 2008
Posts: 129

View Profile
C# and Java solve this problem making templates apply only to types, never numbers, so you won't ever write class X<3>>2>.
Which is one of the reasons that C# and Java suck.  Number templates are extremely useful in some cases.
Well, C# and Java don't really have templates if I'm not mistaken; they just have runtime generics, and with runtime generics it only really makes sense to have type arguments, doesn't it?
Logged
Offline (Unknown gender) luiscubal
Reply #42 Posted on: January 14, 2010, 04:48:27 PM
Member
Joined: Jun 2009
Posts: 452

View Profile Email
Yes, they are called generics in C# and Java.
Now, C# has generics on the runtime. Java doesn't even have that. Generics are a compile-time trick. They are erased from the binary. Which is the number 1 problem with Java generics.
As for C#, I don't see how numeric generics could be used but, then again, I don't see what they're for in C++ either.
Logged
Offline (Male) Rusky
Reply #43 Posted on: January 14, 2010, 09:45:54 PM

Resident Troll
Joined: Feb 2008
Posts: 955
MSN Messenger - rpjohnst@gmail.com
View Profile WWW Email
In C++ you can make statically-allocated containers of varying sizes:
Code: [Select]
template <typename Value, int size>
class Stack {
private:
    Value value[size];
public:
    ...
};
Logged
Offline (Unknown gender) luiscubal
Reply #44 Posted on: January 15, 2010, 05:31:37 PM
Member
Joined: Jun 2009
Posts: 452

View Profile Email
I guess, but you can still use calloc/new[], right? (I know, not compile time, not as efficient)
Logged
Pages: « 1 2 3 4 5 6 »
  Print