Moderators: phlip, Moderators General, Prelates
EvanED wrote:be aware that when most people say "regular expression" they really mean "something that is almost, but not quite, entirely unlike a regular expression"
MHD wrote:Have you ever encountered a language design feature you just though was odd?
I am currently looking at Ruby, and it seems to me that :symbols are largely neglected.
Why does Class.instance_methods return a list of strings and not symbols?
Why is it kosher to say x.responds_to? "method" in steadof x.responds_to? :method
Jplus wrote:C# goes even further by requiring that a class is always wrapped in a namespace.
Carnildo wrote:I've never understood why C has two different operators for accessing structure members ('.' or '->', depending on if your variable is a pointer or not), when there is never a situation where it is valid to use both.
MHD wrote:C++ is, IMHO nothing but this topic.
mister_m wrote:Carnildo wrote:I've never understood why C has two different operators for accessing structure members ('.' or '->', depending on if your variable is a pointer or not), when there is never a situation where it is valid to use both.
Doesn't the arrow operator '->' represent a dereference, and then an access? Where the dot '.' is just an access?
EvanED wrote:Yes, but why should it be that way? If the lefthand operand is a pointer, then . isn't valid, and if it's a structure, -> isn't valid. They could have easily used . in both cases, saying "if the left operand is a pointer, it dereferences first".
headprogrammingczar wrote:What I never got waswhy parens of all things are the syntax forPerllist literals. Way to makethe semantics ofyour language totally incomprehensible, guys.
phlip wrote:EvanED wrote:Yes, but why should it be that way? If the lefthand operand is a pointer, then . isn't valid, and if it's a structure, -> isn't valid. They could have easily used . in both cases, saying "if the left operand is a pointer, it dereferences first".
Yeah, but they're still doing completely different things. You may as well say something completely random, like "printing a string to an output stream should use the same syntax as left shifts, since it's never valid to use both". Such a system would be ridiculous. (But seriously... iostream: WTF.)
EvanED wrote:But more to the point, why is f(x) syntax a legal shorthand for (*f)(x) if f is a function pointer? Those are doing different things. (Actually I think in many ways that's pretty analogous to the . vs -> issue.)
EvanED wrote:be aware that when most people say "regular expression" they really mean "something that is almost, but not quite, entirely unlike a regular expression"
phlip wrote:EvanED wrote:But more to the point, why is f(x) syntax a legal shorthand for (*f)(x) if f is a function pointer? Those are doing different things. (Actually I think in many ways that's pretty analogous to the . vs -> issue.)
That's a good point, actually. I know I'll usually use (*f)(x), to make it clear a function pointer is being used, but the shorthand version is certainly allowed...
Jplus wrote:I find the iostreams approach to output and input much more sensible than the classical approach with formatted strings. It's safer and more readable, it looks better, and it might even be a bit more efficient.
By the way, not to start a flamewar, but I think it was a crazy idea to enforce using so many parentheses in Lisp.
http://en.wikipedia.org/wiki/DSV_Alvin#Sinking wrote:Researchers found a cheese sandwich which exhibited no visible signs of decomposition, and was in fact eaten.
Sagekilla wrote:Someone mentioned the export keyword earlier on, and I have to say I wish more compilers actually supported it.
Templates in C++ can be extremely weird and awkward, more so than they need to be. I wanted to be able to store a
complete interface within a header file, and then put all the implementation details within the cpp file.
Only problem was that since my class was templated, I had to specify the specific versions I wanted to instantiate within
my cpp file before I could even use them.
If that damned export keyword was supported, I could just toss it right in front of my class definition and everything would
be great. But nooo, only Borland C++ supports that.
That being said, I still think C++ is a well designed language. Not to mention one of my favorite ones to work in.
With regards to the typename requirement that was mentioned earlier, there was a question up on SO that actually tackled
that specific issue. It turns out the typename is required because the compiler needs to know it. Without it the compiler can't
properly resolve the types, IIRC.
Jplus wrote:
Iterator syntax in Lua is hard to wrap your head around, especially if you realize that it looks superficially like the iterator mechanism in Python while it works totally different.
EvanED wrote:Believe me, I am well aware of why typename was added. (Google 'typename' -- I wrote the first hit.)
http://en.wikipedia.org/wiki/DSV_Alvin#Sinking wrote:Researchers found a cheese sandwich which exhibited no visible signs of decomposition, and was in fact eaten.
Sagekilla wrote:EvanED wrote:Believe me, I am well aware of why typename was added. (Google 'typename' -- I wrote the first hit.)
I have to say, it's pretty cool to be able to say "Google this C++ keyword. See the first result? Yeah. I wrote that."
The thing about them in Lua is that you get returned a function that returns the next thing each time you call it, not the first item in the list, and you are expected, if you do your own, to accept and store state in anonymous fashion, until the caller of the initializing function returns.Turtlewing wrote:Jplus wrote:
Iterator syntax in Lua is hard to wrap your head around, especially if you realize that it looks superficially like the iterator mechanism in Python while it works totally different.
I found Lua iterators made a lot of sense (they's just a function that returns the next thing every time you call it). But I've never used Python so I might just have dodged the cognitive dissonance of keeping both in my mind at once
// This function cannot throw any exceptions
void foo() throw();
// This function can throw whatever it wants
void bar();
maafy6 wrote:
- Code: Select all
// This function cannot throw any exceptions
void foo() throw();
// This function can throw whatever it wants
void bar();
Understanding the need for backwards compatibility, and the ability to look at throw() as throw empty-set = throw nothing, looking at the two in a vacuum it still makes no damn sense.
void foo() throw ();roband wrote:Mav is a cow.
EvanED wrote:mister_m wrote:Carnildo wrote:I've never understood why C has two different operators for accessing structure members ('.' or '->', depending on if your variable is a pointer or not), when there is never a situation where it is valid to use both.
Doesn't the arrow operator '->' represent a dereference, and then an access? Where the dot '.' is just an access?
Yes, but why should it be that way? If the lefthand operand is a pointer, then . isn't valid, and if it's a structure, -> isn't valid. They could have easily used . in both cases, saying "if the left operand is a pointer, it dereferences first".
That being said, I do actually like the explicitness the two syntaxes present. And once C++ overloading enters the picture, it can be semi-convenient that they are different syntax.
struct Mundane {
static const int I = 42;
};
struct Ambiguous {
Mundane* operator->() { static Mundane m; return &m; }
static const int I = 43;
};
int main() {
Ambiguous a;
printf("%d != %d\n", a.I, a->I);
}
public interface IStringifiable
{
string ToString();
}
IStringifiable position = new Point(42, 69);
ekolis wrote:This might be Windows-API-specific, but surely I'm not the only one who gets annoyed with the various "secure", "fixed", and "final, no, really, we mean it this time" versions of standard library functions which are now deprecated. "Oh, you shouldn't be using sprintf anymore, you SHOULD be using sprintf_secure_v2_fixed_forrealthistime! Otherwise your program will be vulnerable to buffer overflows!" Well, that's all well and good, but why should I have to memorize the fancy names of the latest versions of the standard functions, and what happens to old programs that you don't have source code for? Why not just fix the original functions to begin with, instead of duplicating them and making a huge mess? Sure, you can say that some programs might rely on the legacy behavior... but when was the last time a buffer overflow was a GOOD thing?!
ekolis wrote:This might be Windows-API-specific, but surely I'm not the only one who gets annoyed with the various "secure", "fixed", and "final, no, really, we mean it this time" versions of standard library functions which are now deprecated. "Oh, you shouldn't be using sprintf anymore, you SHOULD be using sprintf_secure_v2_fixed_forrealthistime! Otherwise your program will be vulnerable to buffer overflows!" Well, that's all well and good, but why should I have to memorize the fancy names of the latest versions of the standard functions, and what happens to old programs that you don't have source code for? Why not just fix the original functions to begin with, instead of duplicating them and making a huge mess? Sure, you can say that some programs might rely on the legacy behavior... but when was the last time a buffer overflow was a GOOD thing?!
Now, as for weird stuff in languages I've actually USED... in C#, I can define an interface:
- Code: Select all
public interface IStringifiable
{
string ToString();
}
OK, now all objects in C# already implement ToString, so why can't I do this:
- Code: Select all
IStringifiable position = new Point(42, 69);
The Point class, like all other objects, implements ToString, but because it doesn't *declare* itself as implementing IStringifiable (how could it? I just created IStringifiable myself!) I can't make this assignment, which is rather annoying, as it limits the usability of poorly abstracted libraries that you don't have the source for. (E.g. if some library had a ConstitutionClassCruiser class, as well as a MillenniumFalconPrivateer class, but no ISpaceship interface implemented by the two, and I want to apply common logic to both types of spaceships, I'd have to build in duplicate logic for the two cases.)
edit: oh, one other thing about C#... WHY the hell did they put stuff like Cartesian points and dependency properties in the PRESENTATION LAYER libraries?! I shouldn't have to reference WPF just to use things like that!
Sc4Freak wrote:Now, as for weird stuff in languages I've actually USED... in C#, I can define an interface:
- Code: Select all
public interface IStringifiable
{
string ToString();
}
OK, now all objects in C# already implement ToString, so why can't I do this:
- Code: Select all
IStringifiable position = new Point(42, 69);
The Point class, like all other objects, implements ToString, but because it doesn't *declare* itself as implementing IStringifiable (how could it? I just created IStringifiable myself!) I can't make this assignment, which is rather annoying, as it limits the usability of poorly abstracted libraries that you don't have the source for. (E.g. if some library had a ConstitutionClassCruiser class, as well as a MillenniumFalconPrivateer class, but no ISpaceship interface implemented by the two, and I want to apply common logic to both types of spaceships, I'd have to build in duplicate logic for the two cases.)
You're looking for a structural type system, of which C# doesn't have. C#'s type system is closer to C++ and Java than anything else. Adopting structural typing would have made C# a significantly different language to what it was intended to be - which was "Java but better".
Terry Pratchett wrote:The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it.
Jplus wrote:As far as I know, Haskell is the only other language that has as full-fledged generic programming as C++. And concepts are explicit in Haskell, except that they're called typeclasses. If I remember correctly, you don't need to state explicitly that a type implements a typeclass, but you can do it anyway if the typeclass's default implementation of a function suits your needs.
EvanED wrote:be aware that when most people say "regular expression" they really mean "something that is almost, but not quite, entirely unlike a regular expression"
MHD wrote:Haskell is polymorphic genric programming. It is way different in execution, but on some points similar in use. A Type Class in haskell serves as both Interface, OO Class and Concept all in one go.
Users browsing this forum: whitedonalsdeef, Xeio and 12 guests