- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: variable is named as "system"
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2008 12:02 AM
тАО01-12-2008 12:02 AM
variable is named as "system"
I have some downloaded code in which the variables are declared with name "system". Is it ok to have variable names same as those of functions? I guess it is ok as long as it is a local variable?
Please suggest
TIA
Satya
- Tags:
- symbol scope
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2008 12:31 AM
тАО01-12-2008 12:31 AM
Re: variable is named as "system"
to go looking for it. Wait until the
compiler complains, _then_ start to worry.
Or write a simple test program, and see what
happens. Reality is more reliable than much
of the wisdom you'll get here. Faster, too.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2008 05:42 AM
тАО01-12-2008 05:42 AM
Re: variable is named as "system"
Naming variables the same as functions is not a choice I choose even when the language allows it.
You don't say what language, but you can do it it ones like Perl where variables are prefixed with sigils to denote categories like scalars, lists or arrays, and hashes.
For example, this is legitimate, working code:
#!/usr/bin/perl
use strict;
use warnings;
my $system = 'satya';
print "$system\n";
system("date");
print "$system\n";
If you run it, it will produce (with a correct date and time, of course):
satya
Sat Jan 12 08:42:01 EST 2008
satya
I suppose that someone will point out that I can enlarge on the example above and also declare an array that I name '@system' and a hash that I name '%system" and thus that that ability is a further confusion. Everything is relative.
Regards!
...JRF...
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2008 07:32 AM
тАО01-12-2008 07:32 AM
Re: variable is named as "system"
If these are shell scripts and they are invoked normally as subprocesses, then the (poor practice) is not visible. If the code is sourced inside the current shell (thus defining variables that show up in the set and env commands, then you'll have to rewrite the code. It may work fine but someday you'll spend hours (days?) trying to make something else work. Change the code from system to SYSTEM as a start.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2008 03:46 PM
тАО01-12-2008 03:46 PM
Re: variable is named as "system"
Because of binding order, dld is likely to bind references to the one in your application, not the system(3) in libc.
>as long as it is a local variable?
Right, the linker doesn't even see it.
>Steven: the compiler complains
The compiler won't let you have both a variable and function in file scope.