Talk:Register (keyword)
This article is rated Stub-class on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | |||||||||||
|
User:Boeing720 issues
[edit]@Boeing720: Please read this carefully as I think we have had problems in the past due to an English-Swedish language barrier. I would have broken this out into a bulleted list but I am using numbered in-line points because last time I tried bullets you interleaved your replies with my bullets which makes a mess. You can use these numbers in the same fashion in your reply if you like. 1) This article needs to be for C++ as well to match the article Static (keyword) and because, like static
, this is relevant to both languages. Consistency is important. 2) You removed the only citation (of the C99 specification) and information relevant to C itself (not C++) - that you can't access the location of a register variable in any implementation of C, but you can use sizeof
3) that a binary is "nude" is irrelevant to compiler optimization - in other words whether a compiler puts a variable in a register in the optimization phase has nothing to do with whether it is targeted toward a system with an OS or not. 4) I asked for a cite for which compilers (embedded) register
is still important. I went ahead and looked into this. For example, for the Microchip MPLAB XC32 compiler[1], in accordance with my information on optimizations, "... variables may be allocated to registers as part of code optimizations. For optimization levels 1 and higher, the values assigned to variables may cached in a register." In the XC32 compiler it is not really along the lines of what you indicated because "The register keyword may be used to indicate your preference for the variable to be allocated a register, but this is just a recommendation and may not be honored. The specific register may be indicated as well, but this is not recommended as your register choice may conflict with the needs of the compiler. Using a specific register in your code may cause the compiler to generate less efficient code." The only way it indicates the register keyword will actually be honored is in terms of your preference for a specific register (which itself is a feature unique to that compiler), which it discourages doing. So I would like to see a citation for documentation of a compiler (embedded) that is contrary to this. —DIYeditor (talk) 07:56, 15 July 2017 (UTC)
- Well first things first. IF there is a language barrier here, (that's IF), then I think it's sooner about C vs C++ than anything else.
- Secondly - the C99 standard doesn't work like a new speed limit, it's just one standard among other standards. Further C++ was as of Bjarne Stroustrup back in 1983, c plus a lot more. I did include a reference for the TC.exe compiler. (Which you removed). Mainly the possibility for OOP. All C code was initially considered to also be C++, but not necessarily the other way around. C++ (especially as OOP) a very good language for huge programs. But C has due to its speed remained as the most important language within embedded programming. Whether C still is a part of C++ and similar questions are a matter of discussion, also here. I wrote the
register
article as a C-keyword (reserved wword) and type modifier, brief but absolutely true. And whatstatic
has to do withregister
, more thanvolatile
orauto
, can't I really see. And I have not written about those. - "Proper C" has its main field within embedded programming. By this is meant any device from a new toaster model up to a control system for airliners. It's (usually) developed on desktop PCs etc ,in some cases with help of tools which simulates the hardware for which the software is developed. (The MIPS procsessor is rather widely known for their simulator, but there are others as well) Still much C-embedded programming are made on Microsoft or Borland development software. (But not often, I would argue, on development tools of "visual type" , like Visual Basic, or Delphi. Although there are plenty of such "event-driven" development tools available, not at least from Borland)
- Embedded programming can be made by one single programmer - up to a team of perhaps 50 programmers led by a programming engineer. In such cases (with many involved in the development of the software) are the (senior) programming engineer responsible for the final decision of the hardware (although it can be changed during the development). This is not just a technical issue, but what I would like to call "techno-economic". Regardless of the amount of developers, are excessive hardware equally unsatisfying as hardware that's too weak. But for opposite reasons, "the technical - economical balance". Hence are hardware not rarely programmed "tightly" , especially for mass produced and cheap devices.
- And when using the C-language is the
register
type modifier (and keyword) a tool available for such optimization. Mainly for loop-counters, but not only. - Also - programs designed as embedded systems are "nude", direct communication without any ("other") Operative System. (Although huge embedded programs certainly can be more complex than a PC-Operative system is, and can work like an OS as well. (Like on board an Airbus A380, I presume)
register
isn't "magical" however, and there are many other optimization possibilities (like correct use of pointers) which may help to make the execution of the compiled (and usually linked) code(s) to go faster. This is done at development time, but intended for the final hardware that is going to be used at - and has little to do with the compiler that is used during development. (I just want to be clear about that difference, the XC32 is a compiler and a software (I trust), unlike the processor and other hardware which will execute the final software(s). And since you ask for compilers am I uncertain if you mean the compiler itself ? Or a development environment.) Borland C++ works fine with "register" MSVS from 2001 equally. (if compiling C-code).
- "Use the register storage class specifier to store the variable declared in a CPU register (if possible), to optimize access and reduce code. Items declared with the register keyword have a global lifetime" (Borland help) Are you saying the keyword has vanished in brand new development environments ?
- For C++ usage, have you yourself said "register" is insignificant. So why bother about that ? For C is "register" still a certain aid, during certain circumstances.(Not more than so, and my initial article was indeed brief) It's not possible to direct a register-declared variable to a certain (hardware) CPU-register. That can only be done by writing "already compiled" code, like machine code, or preferably through the use of the assembly code for the intended hardware in question. (the hardware at where the final software(s) will be executed on. It's possible, but very far from easy). The
sizeof
keyword will tell you the number of bytes a variable actually occupies (typically whether int/long are different in size - or equal, doubt that's of interest outside the memory (RAM). But show me a brief example how "sizof" might give some help in combination of a register-optimized variable, if you like. - I stand by my first brief & original article, and think if C++ is necessary to involve, could that part just have followed. Chronological order. However I will leave it up to you. (And I will move this discussion to the talk-page of the article, where it belongs) Boeing720 (talk) 23:01, 15 July 2017 (UTC)
- For C++ usage, have you yourself said "register" is insignificant. So why bother about that ? For C is "register" still a certain aid, during certain circumstances.(Not more than so, and my initial article was indeed brief) It's not possible to direct a register-declared variable to a certain (hardware) CPU-register. That can only be done by writing "already compiled" code, like machine code, or preferably through the use of the assembly code for the intended hardware in question. (the hardware at where the final software(s) will be executed on. It's possible, but very far from easy). The
- All of
static
,register
,volatile
extern
andauto
should have similarly named and laid out articles if they are to have articles at all. I believe of those only Static (keyword) existed so I based my vision for what the article should be named on that and moved Register (C programming language) to Register (keyword) because it is very important that articles be consistently named. Also, likestatic
, since it applies to more than one language, any related language the keyword applies to should be covered in such an article. I don't thinkvolatile
,extern
, andauto
have individual articles but if they did they should be handled in the same way. Consistency. - C99 was just an example of an actual ISO C standard for which I could find the text online. C11 would be better yet but it is not available for free. C99 is a much more solid citation than "TC.EXE" which is not only just one piece of software, it is ridiculously outdated. However it would not really be any better to use the gcc or Visual Studio documentation as citations versus an ISO standard. What C99 says, I believe, was true going back very far in C and I was using it as a source for statements that apply in general.
- I don't know what it has to do with this article how many people work on a piece of code (except that as I want the article to read: if it is declared register, in C you aren't allowed to use it in a way, by accessing the location, that would cause the compiler's optimization not to place it in a register, possibly preventing someone from accidentally misusing a variable intended to be in a register), or why this article should be primarily related to embedded systems. Clearly embedded systems are relevant but so is, say, the Linux kernel. Also, C is not dependent on the implementation or target. It is worth discussing implementations but the standard doesn't depend on them.
- Of course
register
is available. My point is that it does not do much anymore because optimization will put variables in registers anyway if possible, automatically. The main difference is that in C (but not C++) it imposes the limitation that you cannot access the location (say, with the&
operator) of variable declared with register. That is the only significant difference you get by usingregister
in all (that I know of) modern compilers if optimization is enabled. - Only the compiler determines whether a variable is stored in the register. Neither the operating system (or lack of it) or the hardware make that determination. Obviously a compiler is targeted to a specific CPU and linking is targeted to a specific OS but it is the compiler that decides where to put a variable and how to use it. That's why I asked for which compiler you are thinking of where optimization doesn't automatically put variables in registers if beneficial. I gave the example of the Microchip™ XC32 compiler because that is for a very common embedded architecture and you seem focused on embedded. I am trying to work with you. By the way, "nude" is not a term used as you described. It doesn't make sense to make up terminology for technical articles.
- I'm not saying the keyword has vanished in new environments, I'm saying optimization in every modern compiler automatically puts variables in registers if appropriate.
- C++ is relevant because the register keyword still exists there. It is possible with the XC32 compiler, per the cited documentation, to direct a variable to a specific register which is why I included that. That may be a quirk unique to that compiler because I also have not heard of that before. I mostly included that you can use
sizeof
because the C99 standard indicated that was significant, but I think it is clear why you might want to know what size a register variable is. It's silly to ask for an example of how that might be used. - The issue of C vs. C++ was treated separately in my version of the article. The only place I really mentioned C++ was saying "but not in C++ where it is essentially ignored". There wasn't much about C++ to merit a separate section since the information about it could be included in the same sentence. This is different from the Static (keyword) article where
static
has more extensive additional meanings. We could break the discussion about C++ into a separate section though, if you feel my version is confusing. —DIYeditor (talk) 12:54, 18 July 2017 (UTC)
- All of
Nobody's perfect
[edit]- I believe your complaints about my English was related to the list of C-keywords, and the brief describing of them, in a one line column. So the brief explanation had a quite limited space. Hence, did I use abbreviations and cut corners in several other ways. Which, just by the way, also was done in the "original" Swedish text. That might possibly be somewhat of a "linguistic culture clash" ?? I just don't know. But I do know that abbreviations are quite popular in written Swedish, also in an encyclopedic perspective. For instance, Swedish encyclopedias typically only uses the first letter in articles, after its first mentioning. Here follows an example taken from the 1950's "Svensk Uppslagsbok" - article is "Venezuela" (as it's the first one in the 31:st volume, which I just happened to have at hand) and just a few lines from its lead. And I skip the phonetics, as I think I suffered from some kind of disease that day, when phonetics was taught :)
- .
- In Swedish -
- "Venezuela [phonetics] off. Republica de V. , förbundsstat i n. Sydamerika... ...V. gränsar i v. och s.v. till Colombia, i s. till Brasilien och i ö. till Brittiska Guayana (se karta vid Bolivia); till V. höra även [some islands]...."
- .
- In English with the same abbreviations -
- "Venezuela [phonetics] off. Republica de V. , a federal state in n. South America... ... V. borders in the w. and s.w. to Colombia, in s. to Brazil and in e. to British Guayana (see map by Bolivia); to V. does also [some islands] belong"
- .
- In English without abbreviations -
- "Venezuela [phonetics] officially Republica de Venezuela , a federal state in northern South America... ... Venezuela borders in the west and south-west to Colombia, in the south to Brazil and in east to British Guayana (see map by Bolivia); to Venezuela does also [some islands] belong"
- .
- I've got no access to any English (printed) encyclopedia. So I don't know to what extent abbreviations are used in English encyclopedic language. I do however know that we don't need to shorten words as in the example. But regarding that list, I didn't give that much thoughts - not more that to give as much help to the readers as possible. That was perhaps a wrong to do. But with exception of some mocking on my written English at talk-pages and I especially recall when "manner" became "manor" in a sentence, which apparently gave some other contributors an opportunity to make a joke. Which also I found to be really funny, as the "coin dropped down". My self rate has always been 3. I could say, five years ago, that value possibly could have been 2.8 but as one actually improves could it today be 3.2 possibly. That's if we had a decimal self-rate possibility. I am indeed aware of not being native in English, as well as translation in general goes from the foreign language to the native one. But I began to learn English (British English) in third grade.And I have studied the English language for 7 years in primary school and during 3 years in secondary school. (And at university-level have I read litterature in English) Add to that all English/Scottish/Irish and American and Australian television and film, which always been a certain natural help. Just as some 15 visits to England also have been of linguistic benefit. English is also from a linguistic aspect not that far from the Scandinavian languages, and has a simpler grammar compared to the German one. Not even when I was brought to "court" (AN/I) did any of the two "prosecutors" complain about my English. So I don't think you have to worry too much about my English. But I will never become a new Shakespeare. That is however similar to my native language, which I prefer to call Scanian (Swedish with quite a lot of Danish elements, vocabulary as well as pronunciation. Especially the use of guttural-R). Cheers ! Boeing720 (talk) 12:07, 17 July 2017 (UTC)
- @Boeing720: No, it was not just your descriptions of the keywords but rather your whole sentences which contain a few persistent grammatical quirks. I think we may be in the wrong place to discuss this (your talk page would be more appropriate) but I will take the time to give you examples from here and C programming language. Please don't interleave your responses, if any, with my individual points and please do give your responses, if any, below my entire post.
- "It suggest the compiler to store a declared variable in a CPU register, instead of in the memory."
- 4 errors, should be:
- "It suggests that the compiler store a declared variable in a CPU register, instead of in memory."
- "Later has more keywords been added, but most of them are intended to widen the C-language into new areas outside Embedded system."
- 6 errors, including a common one for you where you put the verb before the direct object in cases like "Later has more keywords been added" instead of "Later more keywords have been [were] added":
- "Later more keywords were added, but most of them are [were] intended to widen C into new areas outside embedded systems."
- "Normally does a C-programmer also require a number of functions."
- Another verb order problem, this time putting the verb before the subject or splitting "does require", using "does require" instead of "requires", and hyphenating things that should not be:
- "Normally a C programmer also requires a number of functions."
- "If the amount of keywords are few, does C instead offer a lots of prepared functions."
- Verb problems, amount vs. number, are vs. is, this "does C instead offer" problem again, "a lots" instead of "a lot" which should be "many":
- "While the number of keywords is few, C instead offers many prepared functions." or better "While there are few keywords, C offers instead many prepared [ready-made] functions."
- These errors may seem small but they indicate a much less than "advanced" level of English (more like en-2 than en-3) and seemed to mirror some problems I felt I had in communicating my reasons for adjusting your edits. I appreciate that you are working in a foreign language and mistakes may be made but some of these mistakes seem persistent throughout your work on Wikipedia and leave something of a mess for others to clean up. They are ungrammatical enough to cause some readers significant confusion. But again, my concern was not as much with your grammar mistakes in articles but in there seeming to be a language barrier when trying to communicate with you via edit summaries and in talk pages, although part of that may be related to what I perceive to be knowledge gaps on your part in the technical nature of the topics. It's not a big deal just a bit frustrating. I'm far from a grammar expert myself, just a native English speaker. Certainly nobody is perfect and mistakes happen; hopefully we can learn from them. Thank you for taking the time to explain your background and perspective. —DIYeditor (talk) 13:33, 17 July 2017 (UTC)
- @Boeing720: No, it was not just your descriptions of the keywords but rather your whole sentences which contain a few persistent grammatical quirks. I think we may be in the wrong place to discuss this (your talk page would be more appropriate) but I will take the time to give you examples from here and C programming language. Please don't interleave your responses, if any, with my individual points and please do give your responses, if any, below my entire post.
- A few comments. You kept all the examples to the same part. It's is technical, and I may have prioritized that aspect rather than grammar. As I wrote that part (essentially all related to the C-language, except the original of this article, which was free of actual errors as well as of grammatical ones) You never even bothered to explain why you felt
static
has some kind of "special" relation toregister
. My guess is what you really wanted to be "the opposite of"static
isextern
. - But in retrospect I admit, to have written that part a bit hasty, possibly stressed by you. I should at least have read it a second time. If I had read it a second time, which I normally do, then at least the worst two errors you have found there, would have been corrected. Time stamp is 6:54 (8.52 CEST) and I was going to sleep (not "just woken"). Is this the language barrier, you refer to ? Explaining the circumstances - or were there any question to which I didn't reply ?
- About your actual criticism of that single contribution. "a lots" is indeed awful - indecisive article followed by plural. And naturally the same about "the number of keywords is" - Shame on me ! However you also appear to do serious grammatical mistakes yourself!
- you wrote (above):
- "Verb problems, amount vs. number, is vs. are" (the latter fault have I just replied to)
- This concerns me "bigly" (the new adverb the new President attempted to coin, or at least used. And which Jimmy Fallon repeated without any further comment...) Given your depth analysis of a fraction of my contributions, including the conclusions you then base on this analysis, do I find it rather strange that you make a so serious grammatical error, which clearly indicates that you even can't differ between nouns and verbs entirely! The words "amount" as well as "number" are both nouns, not verbs. Do you think I should begin to examine your grammar ? And are you not aware that there are English speaking foreign nations besides your own, which ever that may be ?
- No ! I'm just attempting to show you, how you come up with your conclusions and verdicts.
- And this isn't funny to read
- "some of these mistakes seem persistent throughout your work on Wikipedia and leave something of a mess for others to clean up." - But then later "It's not a big deal just..." and "Certainly nobody is perfect and mistakes happen; hopefully we can learn from them." I can agree to the two last ones. And that morning which you keep referring to, isn't representative for my contributions, from a grammatical perspective. And I'm an at university level examined programmer of embedded system. And I have sudied C, C++ for OOP, assembly of MIPS, HC11 and some other chip with a smaller instruction set. I have also worked with embedded programming professionally, within the Assa-Abloy concern at a software/hardware developing company called Timelox during 4½ year. (I had never use for C++ there) And right now am I feeling real tired. I can't go through a grammar check right now. Boeing720 (talk) 03:38, 18 July 2017 (UTC)
- A few comments. You kept all the examples to the same part. It's is technical, and I may have prioritized that aspect rather than grammar. As I wrote that part (essentially all related to the C-language, except the original of this article, which was free of actual errors as well as of grammatical ones) You never even bothered to explain why you felt
- Your grammatical problems are at this point probably a bigger issue than the technical, but it is hard to tell. I was only trying to be polite and cooperative when I said it's not that big of a deal. You don't seem to want to acknowledge how many clear errors were contained in the above examples or learn from my corrections (like how you still say "embedded system" instead of "embedded systems" when you mean plural). The "grammatical mistakes" of mine that you try to highlight seem to amount to one item in a list of things that weren't intended to be directly connected - and I wasn't trying to make an addition to an encyclopedia article with that, but rather to save space. I know quite well that "number" and "amount" are nouns; I meant with that list that there were verb problems, and you were confusing "number" with "amount", and "are" with "is", etc. I was giving a list of the (numerous) problems in your sentence, not trying to write a complete sentence. Perhaps I should have gone into more extensive descriptions of the problems with each example in plain English in complete sentences to avoid any confusion, because it is plain that confusion is likely in this exchange. Trying to turn this around on me is a ridiculous way to try to avoid how bad those examples of your text were; I could be terrible at English but that would not make yours any better. It would be obvious to any native English speaker, or advanced level English speaker, that there were clear and significant errors in the sample text I gave. I assure you that in any country where English is spoken those example sentences I gave would be described by everyone as "broken English". I'll accept that maybe this is not indicative of your best English as you do seem to be able to express yourself somewhat more clearly outside the article, which doesn't make sense because in the articles is where it counts. By the way, it would be beneficial to pay closer attention to international news stories if you are going to cite them; Trump didn't make up a new word "bigly", he said "big league" which is itself pretty crappy English but that's another matter entirely. Truth be told, your English was so bad in these two articles that it was quite difficult to tell whether you were having more of a problem with the technical nature of the articles or with English. As to your technical points I will try to respond to your comments above in that section, although to be honest I have trouble understanding your English well enough to do so and it will require some thinking and guessing. —DIYeditor (talk) 12:11, 18 July 2017 (UTC)
- Quote "I'll accept that maybe this is not indicative of your best English" - thanks ! "Amount" is related to quantity - of largely anything and "number" is a synonym. "A number of occasions" usually means "(rather) many times". etc. And I know well, that you know quite well, that "number" and "amount" are nouns. But still you made a mistake. Like I did in the C-article. (OK I made more mistakes than you, did, but still) I had a bad day, obviously.
- I have never ever before been accused of bad grammar before. Not even during my only experience of AN/I. (sorry for the external link)[[2]] If there had been any language problem as well, then I'm pretty certain they would have played that card as well. But neither of them did. And one of the two seems to be extremely hard on "bad English" (in an other AN/I case, which very well may be in the same archive). Boeing720 (talk) 02:31, 19 July 2017 (UTC)
Example disproves
[edit]Wikipedia is not a forum to chat about topics, WP:NOTFORUM. Johnuniq (talk) 21:22, 13 February 2018 (UTC) |
---|
The following discussion has been closed. Please do not modify it. |
@DIYeditor:- this is bullocks "Aside from this limitation, register is essentially meaningless in modern compilers due to optimization which will place variables in a register if appropriate regardless of whether the hint is given." and the example proves it! Boeing720 (talk) 02:49, 10 February 2018 (UTC) # gcc -O1 registertest.c # ./a.out Memory store: 3 ticks
/* don't go over the limit for your int - that's hardware dependable*/ int a,aa,b,bb,c,cc,dd,e,ee,f,ff,g,gg,h,hh,i,ii,j,jj; /* only i and j will be used - the others for simulation of a larger program*/ int main (void) { register int k; register int l; long tmp; clock_t start; /* defined as clock_t variable defined in time.h */ clock_t finish; for (a=1;a<LAPS;a++) {for (aa=0;aa<MAX;aa++);{tmp+=aa/a;}} for (b=1;b<LAPS;b++) {for (bb=0;bb<MAX;bb++);{tmp+=bb/b;}} for (a=1;c<LAPS;c++) {for (cc=0;cc<MAX;cc++);{tmp+=cc/c;}} for (d=1;d<LAPS;d++) {for (dd=0;dd<MAX;dd++);{tmp+=dd/d;}} for (e=1;e<LAPS;e++) {for (ee=0;ee<MAX;ee++);{tmp+=ee/e;}} for (f=1;f<LAPS;f++) {for (ff=0;ff<MAX;ff++);{tmp+=ff/f;}} for (g=1;g<LAPS;g++) {for (gg=0;gg<MAX;gg++);{tmp+=gg/g;}} for (h=1;h<LAPS;h++) {for (hh=0;hh<MAX;hh++);{tmp+=hh/h;}} start=clock(); for (i=1;i<LAPS;i++) {for (j=0;j<MAX*1000;j++);{tmp+=j/i;}} finish=clock(); printf("Memory store: %ld ticks", finish-start); start=clock(); for (k=1;k<LAPS;k++) {for (l=0;l<MAX*1000;l++);{tmp+=l/k;};} finish=clock(); printf("Register store: %ld ticks", finish-start); getchar(); return 0; }
From editing mode this looks fine. I've replaced system with getchar so stdlib.h is no longer requiered. I guess you can use lager numbers - if you just got 3 ticks. It's just to change them as you like in the declare directives. I didn't bother with parameters to the program. Do you wish me to do so ? Boeing720 (talk) 03:56, 10 February 2018 (UTC)
Now I have added workload in all loops, and EMPTY LOOPS cannot be disregarded from, I also reduced the loop counters. Note this I havn't compiled. Just added here. Boeing720 (talk) 04:58, 10 February 2018 (UTC)
Ok, just for fun, I fixed some of your errors (extraneous semicolons, divide by zero, uninitialized variable, no newlines). The test is still poorly designed and I didn't try to fix that. Without optimization (gcc -O0): Memory store: 1588397 ticks Register store: 1274641 ticks Memory store: 1489207 ticks Register store: 1272370 ticks Memory store: 1574000 ticks Register store: 1323891 ticks Memory store: 1507071 ticks Register store: 1269799 ticks With optimization (gcc -O1): Memory store: 138140 ticks Register store: 135433 ticks Memory store: 126543 ticks Register store: 140898 ticks Memory store: 133753 ticks Register store: 145676 ticks Memory store: 131794 ticks Register store: 125634 ticks But the point here is not to debug your shoddy code examples or for us to do original research on what compilers do what. The point is that this rubbish has no place in an encyclopedia article. —DIYeditor (talk) 08:09, 10 February 2018 (UTC)
|
Register in other languages?
[edit]Any other instances of it, apart from C/C++? Andy Dingley (talk) 15:00, 8 November 2019 (UTC)