Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Post Assign

Name: OP !9kbJjvwmwE 2012-12-27 14:19

I find post/pre-increment/decrement very, very useful (I'm refering to x++, ++x etc.). Often it's what saves me from having to declare redundant variables or, god forbid, redundant functions.
The time has come in which I wonder whether this kind of magic is possible with assignment as well (in any language).
In the following JavaScript code, the expression in the parentheses returns the value assigned to the variable x (or the value of x after it had been assigned the new value):
(x = 1)
Is there a language that provides a way to write a similar expression which will return the value of x *before* it's assigned the new value?
An imaginary example would be:
var x = "before";
var y = (x = "after");

in which y will be assigned the value "before" (instead of "after", as it would if this was run as JavaScript).

Better yet, in a language that does *not* provide a native syntax to achieve this, can you think of a hack that do it? For example, in JavaScript, the best way I can think of to achieve this without declaring additional variables is:
var x = "bef";
var y = [x, x = "aft"][0];

Here in the second line I declare an anonymous Array with the first element set to x and the second element set to the result of the expression setting x to the new value, and then retrieve the first element of that array (the second element is irrelevant here) and assign it to y.

In the next post I will explain why such a procedure would ever be useful for anything (which you are likely to ask).

Name: Anonymous 2012-12-27 15:48

>>7
Sympta
Are you fucking braindead? It's Symta, fagshit.

Name: Anonymous 2012-12-27 15:52

>>7
That's surprising. I guess google doesn't index this site. In the mean time, learn lisp.

(defmacro := (lval rval) (let ((temp (gensym))) `(let ((,temp ,lval)) (setf ,lval ,rval) ,temp)))

Name: >>5 2012-12-27 15:54

No >>8-san, I am the fagshit.

Name: Anonymous 2013-09-01 13:19



                 _,,,.........,,,,_
            ,..::''"´:::;::::'´::::::::::`゙'::..、
          .,.::'´::__:::::;::´::::::::::::::::::::::::::::::\
        /:::::''´:::::`::::::::: ̄`゙':::、::::::::::::::::::ヽ,
       .,.:'::/::::::::::::::::::ヽ;::::::::::::::::::\:::::::::::::::::':,
      /::::::::::;:::/ `ヽ,::::::ト、:::::::::::ヽ;:::::「ヽ:::::::::::',
      ,':::/:::::::l/     ';:::::} \::::::::::';::ノ ,ゝ、::::::::l
     ;:::::':::::::;' 二_   |:::,    ヽ;::::r' イ ノ:::::::::;
     l::::i::::::::{ィ´r)ヾ、  レ' _,,.二、ハ::;>‐r'::::::::::/
     |;:::':::::::lr‐弋_リ'r-、-ァ´r) l!`Y!:::::i:::::';::::::::/
     |::,:::、::::'、、" _.ノ   、 ゝ-‐゚メ::::;'::::::|:::::':::::',
      ,::'、::\;ゝ   .     ー "升:/l::::::;:::::::::::::ヽ
      }::/.}::::人    、     /::レ'ノ:::;:'::|:::::::::::::::::\
      ,':/ ノ:;:':::::::\  `  ´   ,:'::::::://:::::;:::::::::::::::::::::::':,
     {:{ ,'::;::::::::/:::/ヽ.,_,,..  イ':::::::/´::::::::/:::::::::::::::::ノ:::::ノ
     r {/::::::::;':: /`ヽ ハ}  |::::::;:':::::::::::/::_;;:: -‐ i''" ̄ヽ
     },:':::::::::::{ /  '-く`''ー-r!:::::{--‐ ''i"´    |    ,
    /::{::::::: r、/    ヽ   l:::::',:::::::::::|__,,... -!_   }
   / ヽ/ヽ:r' 、\    rノー- ,::::::} ̄ ̄|::::::::::::::::::;'>ヽ  ;
  {   ;':::::: }   \\ ノ'、::::::ノ::::;:'__ .ノ::::::::::::/    ∨
   ヽ /7ー、/    \ Y  ̄ /::/     ̄`ア      ',

Name: Anonymous 2013-09-01 14:50



わ からない事は上白沢先生に相談しよう
きっと答えてくれないが気休めにはなるぞ!

┌───────────────────────────
|質問:
└───────────────────────────
       iヽ、
     ____」____ゝ'´/':\ /|        ハクタクシステム Ver.1.00
     ヽ. _/___/___::\/        ____________________________________
      <Y---r二二二二ハ.フ.     |
       ,.L__:::::|::::i::::L-」::l::7>       | 質問の答え:
     /     ̄' 'ー---─' `ヽ.     |
    ./   ,.      ⌒ヽ.     ',     |
   ,'  / / ‐/- i:::::::::::i   `ヽ!.    |
    i   i  !/ア!-;!、ハ:::::::ハ-!、.i . i.   |
   |  ハ .! ! !__r! ' レ' ァ!‐;!、i i |   |
   |  i レ' ! "    ,   !.rハ/レ'ヽ!  <
   |  ! .|ハ、   、..__   "/:::| .|     l___________________________________
    | ./i  |::::!>、._  _,,.. イ .|::::| |  ,.、    __
   .| ./ !,..-|::::|'´/ヽ二ン`7ー、|:::|. | i !,,.-''" ノ
   |/ /  .|::::|〈 イ::::V:::::::::!〉:`i:::ト、! .! ヽ -=ニ__
  .!r〈_   !,ヘ!:::ヽヘハ::::;イノ:::::;ヽ! ヽ,!   !  ‐--,' 「`ヽ_/`i
  !.ゝr、__r、i::::::::::::/ ハ Y::::::::::i  r/ ヽ   ー,--'  ,'ゝ-^ー‐'´ヽ.
  !/  、/ヽ;::::::〈  ハ ',:::::;イ、_ /!   7`  ̄    L!_!ハ!_ハ_i.」 i
  .〈    ヽ、/:::::::::ヽ/Vヽ、〉::::! !`ー,ヽ-'       从゚ ー ゚く」 | |
  .レ\ ,.イ`ヽ:::::::::::::ハ::::::::::::ハ、 |ノ          }>!|,イ〒イヽ! |<{

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List