Redian新闻
>
NSC 485's actual processing time is May 15
avatar
NSC 485's actual processing time is May 15# Immigration - 落地生根
U*y
1
写recursive的程序时, 经常会需要建某个variable或data structure,然后多次用到它
并需要它maintain value between calls. 一般有两种方法可以选择, 一种可以在
recursive的函数里declare它static; 另一种是在函数的wrapper里declare它然后pass by
reference.
一直想知道哪种方法更好,大家有没有什么见解?
avatar
s*t
2
Web posted as 4 months, just called USCIS, was told they are actually
processing cases before May 15. Ft! Thankfully was allowed to do SR for my
LD's case, RD 5/23
avatar
l*8
3
pass by reference 好吧
static local variables 看起来不好理解
avatar
g*x
4
it's great to hear! Last time I called is April 16.
Will ask my ld to do SR as well. the same RD.
bless to you guys!

【在 s*******t 的大作中提到】
: Web posted as 4 months, just called USCIS, was told they are actually
: processing cases before May 15. Ft! Thankfully was allowed to do SR for my
: LD's case, RD 5/23

avatar
S*w
5
static?

pass by

【在 U*********y 的大作中提到】
: 写recursive的程序时, 经常会需要建某个variable或data structure,然后多次用到它
: 并需要它maintain value between calls. 一般有两种方法可以选择, 一种可以在
: recursive的函数里declare它static; 另一种是在函数的wrapper里declare它然后pass by
: reference.
: 一直想知道哪种方法更好,大家有没有什么见解?

avatar
n*g
6
看成march了

【在 s*******t 的大作中提到】
: Web posted as 4 months, just called USCIS, was told they are actually
: processing cases before May 15. Ft! Thankfully was allowed to do SR for my
: LD's case, RD 5/23

avatar
U*y
7
有可能,不过如果pass很多reference的话,函数的参数会太多,也会变得不大好理解吧
还有没有其他方面的考量?

【在 l*********8 的大作中提到】
: pass by reference 好吧
: static local variables 看起来不好理解

avatar
s*t
8
Thanks!
bless your ld too!
Hopefully we will be greened before our trip to China on Nov.12. Cross my
fingers.

【在 g****x 的大作中提到】
: it's great to hear! Last time I called is April 16.
: Will ask my ld to do SR as well. the same RD.
: bless to you guys!

avatar
l*8
9
pass 三四个reference应该不乱。 如果函数的参数实在太多,可以把多个参数合到一
个结构体或者类里面

【在 U*********y 的大作中提到】
: 有可能,不过如果pass很多reference的话,函数的参数会太多,也会变得不大好理解吧
: 还有没有其他方面的考量?

avatar
a*m
10
如果是static,下次重新调用同一个计算的时候怎么办?还要弄一个 bool first_time
的变量?
avatar
a*m
11
还有static也只在单分支递归能用。有两个以上分支就没戏了。参数比static好用而且
清楚多了。
avatar
U*y
12
同意这个, static local variable可能不好还原成初始状态.

time

【在 a********m 的大作中提到】
: 如果是static,下次重新调用同一个计算的时候怎么办?还要弄一个 bool first_time
: 的变量?

avatar
U*y
13
为什么多分枝递归不行,如果是单线程的话

【在 a********m 的大作中提到】
: 还有static也只在单分支递归能用。有两个以上分支就没戏了。参数比static好用而且
: 清楚多了。

avatar
a*m
14
很简单的一个代码,计算一个二茶树的高度,不用参数用static试试看。

【在 U*********y 的大作中提到】
: 为什么多分枝递归不行,如果是单线程的话
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。