a = b – Talk
Killzone Kid (talk | contribs) No edit summary |
Lou Montana (talk | contribs) m (Text replacement - "Link\|https:\/\/en\.wikipedia\.org\/([^w][^i])" to "Link|https://en.wikipedia.org/wiki/$1") |
||
(16 intermediate revisions by 5 users not shown) | |||
Line 15: | Line 15: | ||
--[[User:Alef|alef]] 11:46, 19 June 2008 (CEST) | --[[User:Alef|alef]] 11:46, 19 June 2008 (CEST) | ||
== Language construct == | |||
<dl class="command_description"> | <dl class="command_description"> | ||
<dt></dt> | |||
<dd class="notedate">Posted on October 3, 2014 - 18:38 (UTC)</dd> | <dd class="notedate">Posted on October 3, 2014 - 18:38 (UTC)</dd> | ||
<dt class="note">[[User:MulleDK13|MulleDK13]]</dt> | <dt class="note">[[User:MulleDK13|MulleDK13]]</dt> | ||
<dd class="note"> | <dd class="note"> | ||
The assignment operator is the only operator that isn't really an operator. It is a special construct.<br | The assignment operator is the only operator that isn't really an operator. It is a special construct.<br> | ||
Take for example, the following expression: | Take for example, the following expression: | ||
<code>hello + 5</code> | <code style="display: block">hello + 5</code> | ||
Assuming ''hello'' contained the value ''10'', ''hello'' would evaluate to ''10'', and ''10 + 5'' would finally evaluate to ''15''.<br | Assuming ''hello'' contained the value ''10'', ''hello'' would evaluate to ''10'', and ''10 + 5'' would finally evaluate to ''15''.<br> | ||
<br | <br> | ||
Which is why the assignment operator wouldn't work as a regular operator.<br | Which is why the assignment operator wouldn't work as a regular operator.<br> | ||
Take for example, the following expression: | Take for example, the following expression: | ||
<code>hello = 10</code> | <code style="display: block">hello = 10</code> | ||
If the assignment operator was a regular operator, ''hello'' would first evaluate to ''[[nil]]'' and finally ''nil = 10'', which wouldn't make a whole lot of sense.<br | If the assignment operator was a regular operator, ''hello'' would first evaluate to ''[[nil]]'' and finally ''nil = 10'', which wouldn't make a whole lot of sense.<br> | ||
<br | <br> | ||
To work as a regular operator, and like any other operator requiring a reference to a variable rather than the variable's value (Eg. [[isNil]] and [[publicVariable]]), its syntax would have had to be. | To work as a regular operator, and like any other operator requiring a reference to a variable rather than the variable's value (Eg. [[isNil]] and [[publicVariable]]), its syntax would have had to be. | ||
<code>"hello" = 5</code><br | <code style="display: block">"hello" = 5</code><br> | ||
</dd> | </dd> | ||
</dl> | </dl> | ||
< | |||
<br><br> | |||
@MulleDK13 I have really difficult time understanding what you are trying to say, this is why I moved it here. Are you saying that a = 10; b = a; a = 5; b will have to be also 5? --KK | |||
:No, that's not what I'm saying, at all. What I'm saying is, that if an operator needs the variable '''itself''' and not its '''value''', it must take a string with its name, case in point: | |||
:*[[isNil]] | |||
:*[[publicVariable]] | |||
:*[[publicVariableServer]] | |||
:*[[publicVariableClient]] | |||
:*[[private]] | |||
:*[[for_var|for var]] | |||
:These operators all take a string representing the name of the variable, because if the syntax of ''[[isNil]]'' was: | |||
<code style="display: block">var1 = 42; | |||
'''isNil var1;'''</code> | |||
:Then var1 would evaluate to ''42'', and the function responsible for the ''[[isNil]]'' operator would receive ''42'' as the argument, while it needed a '''reference''' to the variable; just like the [[+]] operator with ''var1 + var1'', would receive ''42'' and ''42'' as arguments, and not a reference to the variables. | |||
:Therefore, the operators take a string containing the name, so the functions responsible for the operators can get a reference to the variable. | |||
:The same would apply if they were to make a binary operator that needed to reference a variable, and not its value. | |||
:And thus the [[=]] operator would need to have the syntax [[String|STRING]] [[=]] [[Anything]]. | |||
:Which is the reason, I assume, they chose to make the [[=]] 'operator' a {{Link|https://en.wikipedia.org/wiki/Language_construct|language construct}}, rather than a regular operator, to remove the need to enclose all the variable names in quotes. | |||
:— [[User:MulleDK13|MulleDK13]] ([[User talk:MulleDK13|talk]]) 02:52, 6 October 2014 (CEST) | |||
::Join the BIKI skype chat http://forums.bistudio.com/showthread.php?131825-Skype-groups-amp-other-contact-groups Most of the active users are here --[[User:Benargee|Benargee]] ([[User talk:Benargee|talk]]) 03:45, 6 October 2014 (CEST)<br> | |||
:::::P.S. you might have to join, leave then join again for it to work properly--Benargee | |||
::This makes much more sense. As I pointed in skype chat, = should not even be in commands category as it is not a command, but a punctuation, just like ;:":)({} etc. --KK |
Latest revision as of 22:11, 23 February 2023
I thought "Equals a to b" is clearer, as it shows that it is an active process, as "a equals b" sounds more like a comparison. But I'm neither a native speaker nor is this command that unclear ;) --raedor 17:51, 16 December 2006 (CET)
- How about this one: Assigns content of b to variable a.. That should be pretty obvious to anybody, what it means. --Kronzky 18:08, 16 December 2006 (CET)
- I think planck confused a = b and a == b. I agree with Kronzky, the new definition is much more clearer. --Sniperwolf572 18:16, 16 December 2006 (CET)
- I can live with that one. :) --raedor 19:27, 16 December 2006 (CET)
- No, Planck didn't confuse this with a == b, I was just at a loss as to where this command comes from as it isn't really in the comref. Anyway the latest definition is fine. Planck 22:43, 16 December 2006 (CET)
Note that array1=array2; array2=[1,2,3]; makes array1=[1,2,3] as well since it's more like a "pointer", not a copy of. array1=+array2 *is* a copy. Confused? :) --Doolittle 18:44, 8 July 2007 (CEST)
b:Anything ?
If b is Anything it could also be Nothing, which in turn cannot be assigned to a variable. --alef 11:46, 19 June 2008 (CEST)
Language construct
- Posted on October 3, 2014 - 18:38 (UTC)
- MulleDK13
-
The assignment operator is the only operator that isn't really an operator. It is a special construct.
Take for example, the following expression:hello + 5
Assuming hello contained the value 10, hello would evaluate to 10, and 10 + 5 would finally evaluate to 15.
Which is why the assignment operator wouldn't work as a regular operator.
Take for example, the following expression:hello = 10
If the assignment operator was a regular operator, hello would first evaluate to nil and finally nil = 10, which wouldn't make a whole lot of sense.
To work as a regular operator, and like any other operator requiring a reference to a variable rather than the variable's value (Eg. isNil and publicVariable), its syntax would have had to be."hello" = 5
@MulleDK13 I have really difficult time understanding what you are trying to say, this is why I moved it here. Are you saying that a = 10; b = a; a = 5; b will have to be also 5? --KK
- No, that's not what I'm saying, at all. What I'm saying is, that if an operator needs the variable itself and not its value, it must take a string with its name, case in point:
- These operators all take a string representing the name of the variable, because if the syntax of isNil was:
var1 = 42;
isNil var1;
- Then var1 would evaluate to 42, and the function responsible for the isNil operator would receive 42 as the argument, while it needed a reference to the variable; just like the + operator with var1 + var1, would receive 42 and 42 as arguments, and not a reference to the variables.
- Therefore, the operators take a string containing the name, so the functions responsible for the operators can get a reference to the variable.
- The same would apply if they were to make a binary operator that needed to reference a variable, and not its value.
- And thus the = operator would need to have the syntax STRING = Anything.
- Which is the reason, I assume, they chose to make the = 'operator' a language construct, rather than a regular operator, to remove the need to enclose all the variable names in quotes.
- — MulleDK13 (talk) 02:52, 6 October 2014 (CEST)
- Join the BIKI skype chat http://forums.bistudio.com/showthread.php?131825-Skype-groups-amp-other-contact-groups Most of the active users are here --Benargee (talk) 03:45, 6 October 2014 (CEST)
- P.S. you might have to join, leave then join again for it to work properly--Benargee
- This makes much more sense. As I pointed in skype chat, = should not even be in commands category as it is not a command, but a punctuation, just like ;:":)({} etc. --KK
- Join the BIKI skype chat http://forums.bistudio.com/showthread.php?131825-Skype-groups-amp-other-contact-groups Most of the active users are here --Benargee (talk) 03:45, 6 October 2014 (CEST)