由买买提看人间百态

topics

全部话题 - 话题: closure
1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)
d*******r
发帖数: 3299
1
一个帖子,转来大家讨论一下
最近使用 closure 和 anonymous function 遇到些问题, 大家探讨一下。
简单说就是当临时写一个 closure 或者 anonymous function 当 callback 使用时候
,如果让这个 closure access 了 external scope 里面的 variable, 就容易出现 "
access mutable variable " 的问题 (WebStorm 就会报 warning).
比如这个帖子里面描述的例子:
http://samwize.com/2013/09/01/how-you-can-pass-a-variable-into-
里面的 callback 引用并使用了 external scope 里面的 i, 所以出错了。
他是通过用 bind( {i: i} ) 将 i 的值传入注册时候的 callback 来解决的,当然也
有其他方案, 比如将 dummy(i, function(response)) 改成 dummy(i, function(
response, i)) 也行。
我在想... 阅读全帖
l****z
发帖数: 29846
2
BY: Lachlan Markay Follow @lachlan
October 2, 2013 12:15 pm
The National Park Service has ordered the closure of a Virginia park that
sits on federal land, even though the government provides no resources for
its maintenance or operation.
The Claude Moore Colonial Farm announced on Wednesday that NPS has ordered
it to suspend operations until Congress agrees to a deal to fund the federal
government.
According to Anna Eberly, managing director of the farm, NPS sent law
enforcement agents to th... 阅读全帖
d******8
发帖数: 3017
3
来自主题: LosAngeles版 - 405 closure
Full Nighttime Closures of the 405 Freeway Planned This Week
Those who travel on the 405 Freeway should expect full directional
closures Dec. 2-4. Though the lane closures won’t begin until10 p.m.,
ramps will begin to close as early as7 p.m.Please plan your commutes
accordingly.
Closure details are as follows:
Monday, Dec. 2 – Southbound 405 Freeway
·The southbound 405 will be fully
closed the night of Monday, Dec. 2, from midnight to5 a.m.on Tuesday
, Dec. 3, from Sunset Boulevard to Wilshire B... 阅读全帖
c****n
发帖数: 54
4
https://petitions.whitehouse.gov/petition/prevent-closure-air-traffic-
control-towers-us-result-budget-control-act-sequestration/3CsfLn46
Prevent the closure of air traffic control towers in the U.S. as a result of
the Budget Control Act - Sequestration
Airport air traffic control towers provide services to pilots that are
essential to the safety, the efficiency, and the smooth operations of
flights. While not all airports have a control tower, airports with towers
are typically very busy and ha... 阅读全帖
h*****4
发帖数: 4219
5
来自主题: Programming版 - 请教一个关于groovy closure的问题
在一个class里面定义一个closure
def person = {
name (nm)
age (ag)
gender (gd)
}
然后想把这个person给打出来
用println的话会打出一个ObjectId 类似于 closure@ahifh42g$
现在的问题是 怎么样把这个closure给打出来呢?
多谢指点!
m****d
发帖数: 156
6
来自主题: MedicalCareer版 - CS closure
My rule of thumb: I would spend as long as I can on closure. The purpose of
closure is to confirm that you got everything right from patient; you have
some but not definitive idea on what's going on ; and you have plan what to
do next based on current clues. Do mention any workup if it helps to justify
your judgement: say you need do rectal exam because you suspect colon
lesion, you need do brain function study(auditory evoked potential) for the
cause of hearing loss. In fact, more goal-oriented... 阅读全帖
c**********3
发帖数: 38
7
看上一个townhouse condo,一排挨着的一个小building.
在网上查到其中一个房子(不是正在卖的这个)在2009的时候有title transfer
between a lawyer and the current owner, transaction type is "lis pendens"/
pre-full closure, 然后transfer价钱是zero.
有没有了解这是什么情况?如果那个房子真的是在2009 full closure 了,会不会对别
的房子有影响?
谢谢先
r**k
发帖数: 1402
8
NE 12th St. Bridge Removal Closure
April 1-4 Full Closure of I-405 in Downtown Bellevue
http://www.wsdot.wa.gov/Projects/I405/NE8thtoSR520/NE12th.htm
d*******r
发帖数: 3299
9
二爷我没有 bash Node 呀,Node 确实写并发挺方便的,特别是各种 Net/File IO,最
近用着确实挺爽的.
我只是觉得写 JS Closure 的时候,我需要注意这个 access external mutable
variables 的问题。
刚刚扫了一眼 CoffeeScript, Coffee 有个 do 关键词就是跟这个有关.
http://coffeescript.org/
When using a JavaScript loop to generate functions, it's common to insert a
closure wrapper in order to ensure that loop variables are closed over, and
all the generated functions don't just share the final values. CoffeeScript
provides the do keyword, which immediately invokes a passed function,... 阅读全帖
d******k
发帖数: 28
10
失敬。
或者这么说吧。人有时候会在某个角拐不过弯来,而在别人看来,那里根本就没有角。
这个问题人人都会发生,我自己也会。琢磨琢磨就会想通了。
比如你下面的说法:
>>>我知道是按照某个顺序修改的 (因为 single threaded),但是如果你一段closure
函数
>>> 里面,正在使用一个变量,但是不确定这个变量的值,那不是很容易写出逻辑错误
。这
>>> 个确实是JS的老pattern了,网上很多帖子讨论的,我是JS新手,最近才学到。
你现在认为的角,其实跟Node 没关系,跟closure没关系,跟concurrent也没关系。 而
是对变量的理解。就像Peking2说的,变量的值本来就是变的,本来就是不确定的。何
需担心。
d******k
发帖数: 28
11
误理解closure中抓到的变量, 有可能。
我另发一帖,应该对理解closure有帮助:
http://www.mitbbs.com/article_t/Programming/31347469.html
b********0
发帖数: 62
12
经典问题 下面这个文章里有讨论
http://book.mixu.net/node/ch4.html
你的帖子里 那个人没搞清楚 例子里根本没有closure
所以和mutable closure没啥关系
d******k
发帖数: 28
13
http://javascript.info/tutorial/closures
当看到LexicalEnviroment/Scope Chain的时候,closure就完全清楚了。
quiz:下面的输出是什么?
//Note: y在func01前没有定义过
function func01() {
function func02(){
y = 10; //如果是var y=10,结果又是什么
console.log( "inner:"+y );
};
func02();
console.log("outer:"+ y );
}
func01();
console.log( "global:"+y );
I*****h
发帖数: 470
14
请一个公司做基因组测序
测完了做了de novo assembly结果还是有很多小gap,而且这个公司做不了gap closure。
请问有可以帮忙做gap closure的公司吗?
谢谢!
h**s
发帖数: 1757
15
来自主题: MedicalCareer版 - CS closure
I do not think u need to mention the + physical finding to the patient at
the closure.
I am still waiting my result , just look as reference:>))
My template of the closure:
Thank you for you cooperation, (smile)
Now I would like to give you a brief review your problem: you came to our
hospital because of ....,..., ... (3 + symptoms). is there anything else you
wanna tell me ?
Okie, thank you !
Based on the infor you gave me and my physical exam , I thought you might
have ...., or .... ( Give t... 阅读全帖
s****s
发帖数: 105
16
来自主题: MedicalCareer版 - 请教CS CLOSURE的一个问题
想请教一下各位考过的XDJM,做CLOSURE时,是否需要详细解释可能的鉴别诊断和检查(用
Medical terms)?还是可以泛泛说一下就可以了,比如 you may have a lung
infection.....we need to order some blood tests and imaging studies......不
同的tutor给的protocol不一样,让我有点confused. 很好奇SP是否知道相应的诊断和
检查,并用来评估我们的CLOSURE?
非常感谢!!!
A**********9
发帖数: 151
17
来自主题: MedicalCareer版 - CS Closure 问题请教
请教大家,Closure部分,需要提做Breast exam, Pelvic exam, Rectal exam这些没有
做的检查吗?我参加了Ximedus,他们没有讲,但是FA中的Closure 都提到了要和病人讲
做这些检查。
d*2
发帖数: 2053
18
http://www.cnn.com/2010/CRIME/05/02/times.square.closure/index.html?hpt=T1
(CNN) -- Several blocks of New York's Times Square remained shut down early
Sunday morning as a robot from the city police department's bomb squad
checked for explosives after an officer saw smoke coming from a box inside a
parked car.
The police department's public information office said the box and other
items found in the search are not confirmed at this time to be a bomb.
The FBI was on the scene as part of the Joint
b*****d
发帖数: 61690
19
来自主题: USANews版 - 周五closure vote
如果成功,周六投票。龟相刚刚file closure
D*******y
发帖数: 104
20
这两天看中了一个银行FULL CLOSURE的房子,昨天我们给的OFFER被接收了,下周要做
INSPECTION,请问各们有没有什么特别要注意的?初次买房:)
j****n
发帖数: 42
21
什么叫银行FULL CLOSURE?
c********r
发帖数: 562
22
FULL CLOSURE, CONFIRMING LOAN都是REALTOR和房地产投资专家的专业术语,你们这些普通买
房人不懂的。
s*******y
发帖数: 1739
23
最近看上一房,去年是SHORT SALE从32万一直到25万,一共在市场上半年多,其间没有任
何PENDING ( 我的BUY AGENT说帮我查的,我有点怀疑),今年又上市了,变成FOR CLOSURE
了,要价29万9,说实话银行这个价格并不是非常便宜,这个房主要新,2006年的,现在在我
们这有个房一样学区,面积还稍大的(大10个SQT),内部装修差不多的2001年的一个房也
才卖29万9,我的疑问是这个房子为什么去年那么便宜还没人要啊,反而到银行手里价格
上去了?有人碰到过这种情况吗?会有什么猫腻里面吗?我们递了28万2 OFFER,银行说让
我们出29万5,我是觉得不值,大家觉还多少钱合适?谢谢
M********I
发帖数: 848
24
以前还正没碰到过pre-full closure, 你确定不是pre-foreclosure?
z*x
发帖数: 895
25
能否细说说,
1)他能拿到与普通房子差不多佣金吗?
2)比如我是新手, BUYER AGENT 是代买过FOR CLOSURE 的老手,will it help?
w******t
发帖数: 16937
26
是是

能否细说说,1)他能拿到与普通房子差不多佣金吗?2)比如我是新手, BUYER AGENT
是代买过FOR CLOSURE 的老手,will it help?
★ Sent from iPhone App: iReader Mitbbs Lite 7.56
h*******8
发帖数: 1217
27
有买过force closure的房子的吗?请问能不能看房子做inspection?
谢谢
W*******n
发帖数: 2762
28
看到一个For Closure得房子还不错,不知道银行能不能一个月内批贷款?因为一个月
内要close.
G**I
发帖数: 102
29
2010 - I-90 Seafair and Blue Angels Closures
The annual SEAFAIR festival begins when the SEAFAIR Pirates land the first
week of July and ends with the Blue Angels flying over Lake Washington in a
spectacular display of aeronautics. The Washington State Department of
Transportation's (WSDOT) role is to make sure drivers and pilots are safe
during the annual event.
The Federal Aviation Administration requires us to close Interstate 90 while
the Blue Angels perform for the safety of both drivers an
t******4
发帖数: 2300
30
SEATTLE - "Hopping" through Seattle could be tough this Easter weekend on
Interstate 5.
Construction crews will close most northbound lanes into the city. That,
together with holiday travel, means delays on northbound I-5 from
Southcenter to Seattle are estimated to be up to 45 minutes this weekend.
Workers will be replacing noisy old expansion joints that create a peculiar
thumping noise under your tires as you head into Seattle.
Northbound I-5 will be narrowed from five lanes to two lanes all ... 阅读全帖
n*****a
发帖数: 1327
31
If I80 has very bad traffic or in closure mode, you may take this detour
back. There is very few traffic on this bypass and it usually remains open
when I80 is closed.
It doesn't always open though. I did a u-turn on it in a very bad storm last
season. The road maintenance effort was totally given up and Donna pass was
blocked by 3' of snow. But if I80 is fully closed, it won't hurt to give it
a try.
When taking this path in snowy condition, please take caution and make sure
to use snowchain on
o**x
发帖数: 901
32
开满鲜花的小镇 (Closure)
1
关于小镇的回忆,
似乎都和鲜花有关。
初到的秋天,
认识你的春天,
无数个尽情挥洒的夏天,
还有那些开满郁金香的冬天,
记忆就像那大大的荷兰风情的风车
在初春料峭的寒意里转动着,
仿佛满目看去,触手可及,鼻息所至的
都是花,
无尽的花,
还有你的气息。
你熟悉的气息,
在这一霎那间,
竟然有些记不起来了。
A
清晨的雨,不停的下,
和每一个昨天一样,
挤上地铁穿梭在繁忙的人群中,
深深的呼吸,
抬头看着雨水滑落的天空。
像极了属于我们的小镇,
一年中的大部分时间都是雨季,
很多人不喜欢那种阴雨绵绵的日子,
可是我却不同,
因为我告诉你啊,
这样的日子,
可以让我这样没心没肺的人啊,
有了难得伤感的理由。
可是,不喜欢纽约的雨,
每一场雨尽管不大
都会伴着狂风。
更喜欢小镇的和风细雨,
即便是三天五天不断的下,
也不会叫人厌烦,
那样的温柔而缠绵,
像极了我们曾经的日子,
那些连月不开的日子,
我们可以手挽着手躺在床上说着这不着边际的话
也可以整天呆在家里没日没夜的看电视剧,
互相给对方作面膜,修指甲
或者一人抱着一本杂志,
互不打搅的看着,睡去。
o**x
发帖数: 901
33
谢谢包子。
这个文章是这样写的,阿拉伯数字部分1,2,3。。。讲的是5年前的事情,顺序。英文
字母部分a,b,c。。。讲的是5年后的事情,是倒叙。两个部分在最后的重叠,就是我决
定把这段感情画上closure的时候。
之所以用这种手法,就是为了表现一下时空交错,物事人非的感觉。同样一首歌,同样
一句话,同样一个事物,5年前和5年后,听起来,说起来,感受起来,已截然不同。
所以读起来有点乱,如果想保持连贯性,可以跳着只读阿拉伯数字。。。

嗯。
i*****s
发帖数: 265
34
GoldenDict 在 Ubuntu 12.04里,经常需要force closure,如果我想重启机子的话
说明GoldenDict不能正常关掉。
你们用什么dictionary software?
d*******r
发帖数: 3299
35
closure accesses external mutable variables 挺危险的... WebStorm 是要报
warning 的呀
我觉得这个理解是对的:
如果想 callback 里的逻辑使用 callback 注册时候的 someObjectRef 的值,岂不是
传入 callback 的时候就得 copy/clone someObjectRef 当时的值?
... ...
这样做的话,就有点像其他 concurrent 模型里面的 "send a variable copy through
a message, but not give reference to the variable".
d*******r
发帖数: 3299
36
二爷你还没仔细读帖子吧,帖子里说的很清楚了呀,而且帖子里面那个例子就是很好的
说明,我copy下来跑过
而且如果你 Google: closure access mutable variable 的话,是有很多其他人的讨
论的
d*******r
发帖数: 3299
37
没说多线程呀,帖子说的是 "因为 single threaded 只是可以让 Node 的代码 access
shared variables 时候不用 lock"。都不用 lock 了,所以所谓 "平行执行的
callbacks" 还是在 single threaded 的主 thread 执行的 (可以算是虚拟平行执行)
,这些执行流程 access shared variable 的问题,是说如果那个 shared variable
是 mutable 的话,多个 (虚拟平行执行的) callbacks 可能修改这个 variable 而不
互相通知。
所以用 closure access external mutable variable 才是有可能有危险的。
我觉得 WebStorm 的 warning 还是挺靠谱的。
d*******r
发帖数: 3299
38
我知道是按照某个顺序修改的 (因为 single threaded),但是如果你一段closure函数
里面,正在使用一个变量,但是不确定这个变量的值,那不是很容易写出逻辑错误。这
个确实是JS的老pattern了,网上很多帖子讨论的,我是JS新手,最近才学到。
t*********h
发帖数: 941
39
这是js入门问题啊 应该是学习2,3天后就应该碰到并理解的了 js不是一直就这样吗
异步的 js的scope是function level的 搞一个function closure就完了
p*****2
发帖数: 21240
40
靠 这个解释太高了

closure
d*******r
发帖数: 3299
41
其实是这样的,有很多变量本来就是拿来所有 模块/进程/host 共享和修改的,比如故
意全局共享的一些状态,或者 remote 端的 DB 里面的一些值,这个确实对所有语言都
一样。这样的话,在任何一个范围内 (e.g. event handler),你 access 这些变量,
都是可能被别的执行单元 (e.g. event handler) 修改过,对这些修改是有心里准备的。
我说那种,还是属于吴用了 Node, 然后觉得这些变量在某个范围内,是不会修改的,
然后其实被修改了,然后逻辑就出错了。还是跟 Node 有关的。想想主要还是async的
注册/执行 event handler 的时间差造成的。消除这个时间差的一个简便办法,就是注
册 event handler 的时候,就 copy 当时想访问的变量的值。

closure
d*******r
发帖数: 3299
42
这个我以前看过,JS community 有个好的特点,就是 posts, blogs 特别多,还都挺
直白不装逼
这个也不错: http://javascriptissexy.com/understand-javascript-closures-with-ease
d******k
发帖数: 28
43
看来你还没有得到它。
这个Quiz的寓意是function不仅可以用closure抓到变量,还可以往global里创造变量。
p*****2
发帖数: 21240
44
来自主题: Programming版 - 请教一个关于groovy closure的问题
这就是closure?
l******t
发帖数: 55733
45
来自主题: Programming版 - 请教一个关于groovy closure的问题
这是带一个it的closure
1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)