I wish I could make my own keywords #3

  • Follow


Think for a moment about the compiler checking const correctness adds.

Then, imagine a c++ with a syntax where we could create our own 'const' 
like qualifier keywords.

In a multi threaded development environment one could imagine wanting to 
declare a 'threadsafe' qualifier.
declare_qualifier threadsafe;

threadsafe would be a qualifier for methods - methods qualified as 
threadsafe would cause compiler errors if they attempted to call non 
threadsafe qualified methods.

Or, in the context of processing data from the user

   declare_qualifier unsanitized;

Now, with some 'rules', we could create a keyword that would be used to 
guard data directly entered by the user, and functions that work on that 
data. Functions not expecting unsanitzed data would be disallowed from 
reading or writing to unsanitized variables.
Conversion functions would use casting, and actual data parsing, to move 
the data from a unsanitized into a 'sanitized' (or non-unsanitized) 
buffer at which point it could be passed safely to SQL or other layers 
in the app that are not so careful about what they process.

Im sure these are not the only two uses possible for custom qualifiers, 
and the rules for each one, to work in their role successfully, would 
have to have some way of being specified. But its time I think that 
compiers tried harder to allow programmers to write 'correct' software 
using tools more versatile than just 'const'.
0
Reply chris.becke (32) 9/17/2009 7:24:18 AM

On Sep 17, 3:24=A0am, Chris Becke <chris.be...@gmail.com> wrote:
> Think for a moment about the compiler checking const correctness adds.
> Then, imagine a c++ with a syntax where we could create our own 'const'
> like qualifier keywords. [...]

You might find this interesting:

  http://www.artima.com/cppsource/codefeatures.html

Sean
0
Reply sean_in_raleigh (45) 9/17/2009 2:34:06 PM


1 Replies
29 Views

(page loaded in 0.045 seconds)

Similiar Articles:
















6/20/2012 5:35:14 AM


Reply: