variable-names

Is _ (single underscore) a valid C++ variable name?

假装没事ソ 提交于 2019-12-03 23:49:17
问题 With gcc 4.7.2 this compiles just fine for me: int main() { int _ = 1; return 0; } Can I expect this to compile in general? I've read the answers about underscores as prefixes. But what if the underscore isn't prefixing anything? 回答1: Yes, from The C++ Programming Language, 4th Edition: A name (identifier) consists of a sequence of letters and digits. The first character must be a letter. The underscore character, _, is considered a letter. 回答2: According to Stroustrup (3rd edition, section 4.9

Is there a length limit on g++ variable names?

≯℡__Kan透↙ 提交于 2019-12-03 23:00:28
See title​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​ Michael Aaron Safyan Short Answer: No Long Answer: Yes, it has to be small enough that it will fit in memory, but otherwise no, not really. If there is a builtin limit (I don't believe there is) it is so huge you'd be really hard-pressed to reach it. Actually, you got me really curious, so I created the following Python program to generate code: #! /usr/bin/env python2.6 import sys; cppcode=""" #include <iostream> #include <cstdlib> int main(int argc, char* argv[]) { int %s = 0; return 0; } """ def longvarname(n): str="x"; for i in xrange

Variable names in Python cannot start with a number or can they?

岁酱吖の 提交于 2019-12-03 22:14:58
This is somewhat academic, but nevertheless. Python syntax forbids starting a variable name with a number, but this can be sidestepped like so: >>> globals()['1a'] = 1 >>> globals()['1a'] 1 Likewise for locals() . Does that mean that Python actually allows it, and that it's just not very visible? edit: My question is not whether it is allowed; I am aware that it is formally not allowed in Python. The question is why can I work around it by addressing globals() directly, and if that breaks certain rules or guidelines, or if it maybe even have a good reason/application to allow that. Python

Why can't variable names have spaces in them? [duplicate]

流过昼夜 提交于 2019-12-03 08:23:21
This question already has answers here : Is there any language that allows spaces in its variable names [closed] (2 answers) Related: Why can't variable names start with numbers? Is there a technical reason why spaces aren't allowed in variable names or is it down to convention? For example, what's stopping us from doing something like this?: average score = sum of scores / number of scores The only issue that comes to mind is keywords, but one could simply restrict the use of them in a variable name, and the lexer would be able to distinguish between part of a variable and a keyword. There’s

How to extract variable names from a netCDF file in R?

為{幸葍}努か 提交于 2019-12-01 03:28:34
I am writing a function in R to extract some air quality modelling data from netCDF files. I have the Package "ncdf" installed. In order to allow other users or myself to choose what variables to extract from a netCDF file, I would like to extract the names of all variables in the file, so that I can present in a simple list rather than just print.ncdf() the file to give too much information. Is there any way of doing it? I tried unlist() to the var field of the ncdf object but it seemed that it returned the contents as well... I googled and searched stack* overflow * but didn't seem to find

Is _ (single underscore) a valid C++ variable name?

扶醉桌前 提交于 2019-12-01 03:08:56
With gcc 4.7.2 this compiles just fine for me: int main() { int _ = 1; return 0; } Can I expect this to compile in general? I've read the answers about underscores as prefixes . But what if the underscore isn't prefixing anything? A name (identifier) consists of a sequence of letters and digits. The first character must be a letter. The underscore character, _, is considered a letter. From The C++ Programming Language, 4th Edition. According to Stroustrup (3rd edition, section 4.9.3), an identifier consists of a sequence of letters and digits. The first character must be a letter. The underscore

How to extract variable names from a netCDF file in R?

[亡魂溺海] 提交于 2019-11-30 23:18:58
问题 I am writing a function in R to extract some air quality modelling data from netCDF files. I have the Package "ncdf" installed. In order to allow other users or myself to choose what variables to extract from a netCDF file, I would like to extract the names of all variables in the file, so that I can present in a simple list rather than just print.ncdf() the file to give too much information. Is there any way of doing it? I tried unlist() to the var field of the ncdf object but it seemed that

PHP: Variable function name (function pointer) called ; How to tell IDE my function is called?

那年仲夏 提交于 2019-11-30 14:37:18
问题 I'm currently trying to remove all errors and warnings I have in my project the Inspection tool from my PHPStorm give to me. I encounter a snippet PHPStorm says "Unused private method _xxx" while it's actually used, but in a dynamical way. Here is a simplifyed snippet: <?php class A { private function _iAmUsed() { //Do Stuff... } public function run($whoAreYou) { $methodName = '_iAm' . $whoAreYou; if (method_exists($this, $methodName)) { $this->$methodName(); } } } $a = new A(); $a->run('Used

Using the component ID as widgetVar name

痞子三分冷 提交于 2019-11-30 09:00:39
I have a simple question about component IDs and dialog (or other components) widget variable name. Is there a problem of using the component ID as widget variable name of the same component? E.g. <p:dialog id="dlgRelConsultasRealizadas" widgetVar="dlgRelConsultasRealizadas" .../> This piece of JSF generates basically the following HTML (not exactly that, but in effects the same): <body> <div id="dlgRelConsultasRealizadas">...</div> <!-- Component ID --> <script>var dlgRelConsultasRealizadas = ...;</script> <!-- Widget var --> </body> Interner Explorer has problems with this approach. For some

Subsetting a dataset by selecting variables based on keywords in their name in SAS

巧了我就是萌 提交于 2019-11-29 16:30:52
I hope someone can help. I have a large dataset imported to SAS with thousands of variables. I want to create a new dataset by extracting variables that have a specific keyword in their name. For example, the following variables are in my dataset: AAYAN_KK_Equity_Ask AAYAN_KK_Equity_Bid AAYAN_KK_Equity_Close AAYAN_KK_Equity_Date AAYAN_KK_Equity_Volume AAYANRE_KK_Equity_Ask AAYANRE_KK_Equity_Bid AAYANRE_KK_Equity_Close AAYANRE_KK_Equity_Date I want to extract variables that end with _Ask and _Bid without knowing the rest of the variable's name. Is there a way to do that? I want to try using a