Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #16229
| Path | csiph.com!usenet.pasdenom.info!news.albasani.net!news2.arglkargh.de!news.karotte.org!uucp.gnuu.de!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail |
|---|---|
| Content-Type | text/plain; charset="ISO-8859-1" |
| Message-ID | <1574086.9R1ReOYYeM@PointedEars.de> (permalink) |
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Reply-To | Thomas 'PointedEars' Lahn <cljs@PointedEars.de> |
| Organization | PointedEars Software (PES) |
| Date | Fri, 28 Sep 2012 15:39:17 +0200 |
| User-Agent | KNode/4.4.11 |
| Content-Transfer-Encoding | 7Bit |
| X-Face | %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&.<b';Md8`dH6iqhT)6C^.Px|[=M@7=Ik[_w<%n1Up"LPQNu2m8|L!/3iby{-]A+#YE}Kl{Cw$\U!kD%K}\2jz"QQP6Uqr],./"?;=4v |
| Face | iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEXTxa4RFk5dUWANED8PFEfy7+MGBiW+n3ZNF/QuAAACaElEQVQ4jVXUwVOcMBQG8Dc7Rc4PUntdWV2uxjDpGaGeozOp1woar4jd5t/v9wLstMwsA/ntlxdCAgUc1hjTc9/JCZfGoo3wG3HdmdAWrIJRHe7GM/TmpY5VFefuVcAkkPbLIaN8rmPmjloyZxgyR3GuJ4K0AGtJ2htz8o7yqikm759fldQXaMpbDzjKAG+8v+AugVTOPO5DOjLvGtUYQwh0CPjnVMyGd+8/GfUB5nLKJDD2aLDh5HYyMDJGDwQIo2ZmZcKbowNmAdB/AzyFhrmF2MHRb0QJJfaAnwGB6orZhoykLzJtGwF/xpYxI1dswomiUj3gTuAIqCn/4C7cULwGNBtwMTk3Y4LfKB5YUaOKBKYtpplm7u0vip8tU1NWWyI/7XdcSuIDoMt6rVHMWT0DbjHPGqDqZVSa6zleLcUTcIKLoMv3ueJluALtAo9B302zPPlrtiVScRdCjXvVh3e3JpYa/jjkuC9N+LrBMlz/eAN4eQijX2EdLo6c5tGGHwLyHFtXk89dDGHwCVhG9T0S/j55AhRZgkMCmUQXJ49TnS1wnQDvw0eAh9ICeMmEFbCnPMFzjAvsWoEWEFdYEx+S0MoUZ1gT1wId8+AF3Bl2OoEu906AUHx5VLw/gXYg/x84loOah/2UYNrgiwSwGO7RfUzVBbx/kgpckumGOi6QirtD6gkLTitbnxNol47S2jVc2vsN5kPqaAHT8uUdAJM4v/DanjYOwmUjWznGfwB7sGtAtor5BgofDuzaRj4kSQAqDakTsKORa3Q3xKi3gE1fhl71KRMqrdZ2AWNNg/YOhQyrVBnb+i+nEg4bsDA+egAAAABJRU5ErkJggg== |
| Subject | Re: Who's eaten my apple and why? |
| Newsgroups | comp.lang.javascript |
| References | <37c94a7b-70f8-47f5-b5b8-2a1b3350de43@u19g2000yqo.googlegroups.com> <k403fb$o5g$1@speranza.aioe.org> <f097689vq8t2i4d344qhsse20dg9jephgj@4ax.com> <k40ct8$fmi$1@news.albasani.net> <kde7681jjln1ffu43grf11thd274pqkokf@4ax.com> <k41bjn$bdg$1@speranza.aioe.org> <pmv868t6raj29735oalaj0imefgpsj8uh1@4ax.com> <k421h5$7ka$1@speranza.aioe.org> <k42a3d$3ni$1@news.albasani.net> |
| Followup-To | comp.lang.javascript |
| MIME-Version | 1.0 |
| Lines | 47 |
| NNTP-Posting-Date | 28 Sep 2012 15:39:18 CEST |
| NNTP-Posting-Host | 4759b2c8.newsspool1.arcor-online.net |
| X-Trace | DXC=eWFUbjhbF6V1`E>oC;JXEZic==]BZ:af^4Fo<]lROoRQnkgeX?EC@@PKPeR?^YhTLWDZm8W4\YJN\R=i2=[N6Y6ZgYTh<TYC1Q_K;=j959J57Y |
| X-Complaints-To | usenet-abuse@arcor.de |
| Xref | csiph.com comp.lang.javascript:16229 |
Followups directed to: comp.lang.javascript
Show key headers only | View raw
Stefan Weiss wrote: > I was talking about reference types with a co-worker a couple of months > ago, and we found an analogy that seemed to help: > > One can imagine variables as small envelopes, just large enough to hold > a single piece of paper. Some things can fit on this piece of paper > entirely, like numbers and strings, others are too large, like objects. > > When you create an object, it's like handing your cloak (the object) to > a checkroom attendant. He will put the cloak on a rack and hand you a > paper receipt to identify it later. You put this piece of paper in your > envelope: your variable now contains a reference to an object. > > Now you can use this receipt to access your cloak anytime. You can copy > the receipt to another envelope and it will still work. You can show it > to other attendants (methods), who will copy it from you and can now > also access your cloak. > > When you empty your envelope, you lose the reference. The cloak still > exists, but you won't be able to find it again. After a while, the > checkroom attendant may (or may not) notice that this cloak has been > hanging around for weeks, and will throw it away (objects with a > reference count of zero may be garbage collected). > > The analogy is getting a little stretched now, but bear with me... > > When you write options.add(o), that's like showing your receipt to an > attendant and saying "take this cloak from wherever it is and hang it on > the tree outside" (the DOM tree). You can do that any number of times, > but in the end your cloak will be hanging on the tree only once. If you > put something else in your envelope, like a blank piece of paper (o = > null), the cloak on the tree is unaffected by this. You just don't have > an easy way to find it again. This is arguably the best analogy for this mechanism that I have read so far. And it is funny, too. +1 PointedEars -- Anyone who slaps a 'this page is best viewed with Browser X' label on a Web page appears to be yearning for the bad old days, before the Web, when you had very little chance of reading a document written on another computer, another word processor, or another network. -- Tim Berners-Lee
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Who's eaten my apple and why? justaguy <lichunshen84@gmail.com> - 2012-09-26 14:43 -0700
Re: Who's eaten my apple and why? Christoph Becker <cmbecker69@gmx.de> - 2012-09-27 01:35 +0200
Re: Who's eaten my apple and why? justaguy <lichunshen84@gmail.com> - 2012-09-26 17:46 -0700
Re: Who's eaten my apple and why? Stefan Weiss <krewecherl@gmail.com> - 2012-09-27 03:51 +0200
Re: Who's eaten my apple and why? justaguy <lichunshen84@gmail.com> - 2012-09-26 19:44 -0700
Re: Who's eaten my apple and why? Stefan Weiss <krewecherl@gmail.com> - 2012-09-27 22:06 +0200
Re: Who's eaten my apple and why? Gene Wirchenko <genew@ocis.net> - 2012-09-26 17:59 -0700
Re: Who's eaten my apple and why? Stefan Weiss <krewecherl@gmail.com> - 2012-09-27 04:16 +0200
Re: Who's eaten my apple and why? Gene Wirchenko <genew@ocis.net> - 2012-09-26 19:38 -0700
Re: Who's eaten my apple and why? Stefan Weiss <krewecherl@gmail.com> - 2012-09-27 05:44 +0200
Re: Who's eaten my apple and why? Gene Wirchenko <genew@ocis.net> - 2012-09-27 09:28 -0700
Re: Who's eaten my apple and why? Tim Streater <timstreater@greenbee.net> - 2012-09-27 17:40 +0100
Re: Who's eaten my apple and why? Gene Wirchenko <genew@ocis.net> - 2012-09-27 16:24 -0700
Re: Who's eaten my apple and why? Dr J R Stockton <reply1239@merlyn.demon.co.uk.invalid> - 2012-09-29 20:47 +0100
Re: Who's eaten my apple and why? Christoph Becker <cmbecker69@gmx.de> - 2012-09-27 13:00 +0200
Re: Who's eaten my apple and why? Gene Wirchenko <genew@ocis.net> - 2012-09-27 09:34 -0700
Re: Who's eaten my apple and why? Christoph Becker <cmbecker69@gmx.de> - 2012-09-27 19:14 +0200
Re: Who's eaten my apple and why? Stefan Weiss <krewecherl@gmail.com> - 2012-09-27 21:40 +0200
Re: Who's eaten my apple and why? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-09-28 15:39 +0200
Re: Who's eaten my apple and why? Gene Wirchenko <genew@ocis.net> - 2012-09-27 16:25 -0700
Re: Who's eaten my apple and why? Tim Streater <timstreater@greenbee.net> - 2012-09-27 08:52 +0100
Re: Who's eaten my apple and why? Gene Wirchenko <genew@ocis.net> - 2012-09-26 17:50 -0700
csiph-web