Attribute wanted

  • Thread starter Thread starter Armin Zingler
  • Start date Start date
Herfried said:
I don't think that using an attribute/compiler warning is a good idea
in this case, because it depends on the calling context whether or
not the warning makes sense.

Instead, I'd introduce a new member (method or property) returning
the more strict type.

If I hadn't already changed the type and didn't remember where I've added
type casting before, I wouldn't have asked if such an attributed exists. :-)
Just curious. Not intended to be used in general.


Armin
 
So this is just a way to find out where something is called ? You could
perhaps just use "Find references" in VS or do a file search. It seems a
one shot search/replace to me.

I was just thinking the same. This seems like a rather drastic method of
debugging code imo.

I would just do it the hard way and locate all references manually then
change them accordingly.

Nick.
 
So this is just a way to find out where something is called ? You could
perhaps just use "Find references" in VS or do a file search. It seems a
one shot search/replace to me.

I was just thinking the same. This seems like a rather drastic method of
debugging code imo.

I would just do it the hard way and locate all references manually then
change them accordingly.

Nick.
 
nak said:
I was just thinking the same. This seems like a rather drastic method
of debugging code imo.

I would just do it the hard way and locate all references manually then
change them accordingly.

I think what he wants is basically in already in C/C++ and C#, more
compiler directives for whatever purpose one needs and there a many
reasons for them.

In C#, there are these two:

#warning message
#error message

--
 
nak said:
I was just thinking the same. This seems like a rather drastic method
of debugging code imo.

I would just do it the hard way and locate all references manually then
change them accordingly.

I think what he wants is basically in already in C/C++ and C#, more
compiler directives for whatever purpose one needs and there a many
reasons for them.

In C#, there are these two:

#warning message
#error message

--
 
Guys, you're making it much more complicated than necessary. Don't care
about the bracketed background information I gave. I've done it another way
long ago. It was just the trigger why the question I asked came into my
mind. It was a spontaneous thought, and as I didn't find such an attribute,
maybe useful for other purposes as well (or better), I asked here.
 
Guys, you're making it much more complicated than necessary. Don't care
about the bracketed background information I gave. I've done it another way
long ago. It was just the trigger why the question I asked came into my
mind. It was a spontaneous thought, and as I didn't find such an attribute,
maybe useful for other purposes as well (or better), I asked here.
 
Armin said:
... It was a spontaneous thought, and as I didn't find such an attribute,
maybe useful for other purposes as well (or better), I asked here.

Armin, you are probably aware of the <Conditional(CONST or DEFINE)>
attribute but I found this interesting. :-)

<Conditional("TEST")> _
Private Sub Test()
...
End Sub

The main purpose is to satisfy the compiler but it will never called
the function come run time.

This is useful to place test() in various spots throughout your code:

...
...
Test()
...
...
Test()

and the compiler will only link in the test() method if the TEST
constant is defined. This is great because it saves one from doing
(like me <g>)

...
...
#if TEST then
Test()
#end if
...
...
#if TEST then
Test()
#end if

In C/C++ this can done with a #define macro translation

#ifdef TEST
# define Test()
#endif

which the compiler will replace all occurrences of Test() calls with
nothing thus nullifying the statement.

What would be useful if the condition allows a GetType to see if a
class exist.

Anyway, thought I would share this for anyone who didn't know about it.

--
 
Armin said:
... It was a spontaneous thought, and as I didn't find such an attribute,
maybe useful for other purposes as well (or better), I asked here.

Armin, you are probably aware of the <Conditional(CONST or DEFINE)>
attribute but I found this interesting. :-)

<Conditional("TEST")> _
Private Sub Test()
...
End Sub

The main purpose is to satisfy the compiler but it will never called
the function come run time.

This is useful to place test() in various spots throughout your code:

...
...
Test()
...
...
Test()

and the compiler will only link in the test() method if the TEST
constant is defined. This is great because it saves one from doing
(like me <g>)

...
...
#if TEST then
Test()
#end if
...
...
#if TEST then
Test()
#end if

In C/C++ this can done with a #define macro translation

#ifdef TEST
# define Test()
#endif

which the compiler will replace all occurrences of Test() calls with
nothing thus nullifying the statement.

What would be useful if the condition allows a GetType to see if a
class exist.

Anyway, thought I would share this for anyone who didn't know about it.

--
 
Back
Top