I wish I could make my own keywords #2

  • 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/11/2009 3:04:09 PM

On 11 Set, 17:04, 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.
>
> 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.

http://www.ddj.com/cpp/184403766

>
> Or, in the context of processing data from the user
>
> =A0 =A0declare_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 xtrigger303 (47) 9/14/2009 11:13:02 AM


On 14 Set, 13:13, Francesco <xtrigger...@gmail.com> wrote:
[snip]

Hi Francesco, hi everybody,
just dropped in to tell that I'm extending my nickname to report my
full name - just to avoid confusion with the other Francesco who was
posting here before of my arrival.

Sorry for the OT post, have a good continuation in this thread.

Cheers,
Francesco S. Carta
0
Reply entuland (631) 9/14/2009 1:16:31 PM

2 Replies
24 Views

(page loaded in 0.051 seconds)

Similiar Articles:













7/27/2012 4:25:57 PM


Reply: