passing array of floats (or vectors) into another function - datascope - hmmm. Very ugly...

V

Victor Bazarov

Because that is not thread-safe ? Not sure I understand why "global" was
used sloppily, neither not sure of the purpose of this get_the_data()
function. Isn't this get_the_data() function a global function, so
instead foo could just as well be a global variable - the result is the
same: Ugly?

Foo is static, so it exists until the program terminates... Static is
not thread-safe, right? I think I can see that this doesn't really help
much, I'm just only 95% sure of the explanation...

Well, at least it does give you the ability to track (by adding some
kind of logging code) when access to the data is made. Beyond that,
there is no difference, I believe.

V
 
J

Jorgen Grahn

Because that is not thread-safe ? Not sure I understand why "global" was
used sloppily,

Because when I myself hear "global" I think "global" as in

int foo;

at the top-level, not static as in

static int foo;

or static inside a function or class.
neither not sure of the purpose of this get_the_data()
function.

There is no purpose, other than to illustrate my point.

/Jorgen
 
S

someone

Because when I myself hear "global" I think "global" as in

int foo;

at the top-level, not static as in

static int foo;

or static inside a function or class.

Ah, I see... I think I understand you.
There is no purpose, other than to illustrate my point.

Ok, thanks.
 
S

someone

Well, at least it does give you the ability to track (by adding some
kind of logging code) when access to the data is made. Beyond that,
there is no difference, I believe.

Yep, agreed, thanks.
 
S

someone

By the way: How come you code on that webpage? Or I assume you made the
program on your own pc and then copy/pasted it?

perhaps OT... but

- I don't need to create a project everytime.
- I can use the latest compiler...
- It's a nice way of sharing ideas. It's certainly a
better way of looking at the code that using a
newsreader. [You] can compile and run it
immediately
- The only disadvantage I see is that I don't know
how persistent the code is (how long it will remain
there).

Of course when I do work I code on my PC/Notebook etc.

Ok, I see... I still prefer my own pc which compiles without "lagging" :)
Glad to be of help.

And a very good help, you were :)
 
8

88888 Dihedral

Manual morphing the type of a pointer which points to different types in the run time without a clear purpose is a useful trick, but this trick is not recommended in C++ most of the time.
 
J

Jorgen Grahn

Manual morphing the type of a pointer which points to different
types in the run time without a clear purpose is a useful trick, but
this trick is not recommended in C++ most of the time.

I *think* I agree with what you *really* mean, but what you write
makes no sense. How can something "without a clear purpose" be a
"useful trick", and what do you really mean?

/Jorgen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top