It puts the data in the bucket…

Matrix4f* Multiply(Matrix4f* a, Matrix4f* b, Matrix4f* d)

Ok, this code could immediately benefit from a good “learn to const, wtf” slapping.

 Matrix4f* Multiply(const Matrix4f* a, const Matrix4f* b, Matrix4f* const d)

Ok – that’s still confusing. I know it’s petty, but there are times when I really wish that C++ would borrow from The Almighty Wall and allow the odd tidbit of syntactic sugar (as opposed to syntactic vomit).

Matrix4f& Multiply( (const Matrix4f* a, const Matrix4f* b) =>(Matrix4f* const d) );

Matrix4f& Multiply( (const Matrix4f* a, const Matrix4f* b) ->(Matrix4f* const d) );

Matrix4f& Multiply( (const Matrix4f* a, const Matrix4f* b) :>(Matrix4f* const d) );

Matrix4f& Multiply( const Matrix4f* a, const Matrix4f* b => Matrix4f* const d );

In perl, ‘=>’ is treated specially inside certain types of lists, being treated as a substitute for “,”. In this case, you could put constraints on it such as: It may only be followed by non-const parameters.

But I’d also like some way to indicate that the return value is one of the input parameters; in this case it’s there so that it fits nicely with operator= etc.

I know C# has “in” and “out” specifically it needs to be punctuation. But then C# already reduced the amount of punctuation over C. (I really don’t understand why C++ hasn’t gone to replacing “.” and “->” with “.”; is there actually a case where using the wrong one isn’t a compiler error???)


With PO pointers, it might work, but if you use e.g. the boost “shared_ptr”, then -> is used to dereference the pointer while . is used to access the shared_ptr members (like reset()). So classes that emulate pointers wouldn’t seem to work without the distinction.

Btw, about the “syntactic vomit”, that still looks better than using boost::lambda… not that that says much. I was excited when I found out about them, but I’ve realized that unless you only want a straight operator expression, debugging the lambda is about 10x more work than just capitulating and defining the function.

It’s sort of sad when the functionality is added but in such a way that it’s such a pain to use that you lose the whole point of adding them in the first place. I use python lambdas all the time and whenever I come across needing one in C++ I just get depressed.

Yeah, I’ve been looking at some of the deeply recursive functions in the client. You can use a struct/class to encapsulate them and reduce the stack depth but it lacks for legibility; what you really want is a nice closure. I know boost provides a closure feature but I still find that messy to read.

Leave a Reply

Name and email address are required. Your email address will not be published.

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

You may use these HTML tags and attributes:

<a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <pre> <q cite=""> <s> <strike> <strong> 

%d bloggers like this: