由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - 估计javascript 最初设计时就基本没考虑好scope问题
相关主题
FP有的,Python都有!C语言重复定义问题
看了这篇文章关于Javascript Closure就醍醐灌顶了很大的C++程序怎么去读啊?
python的scope机制 非常垃圾请问这个C++程序有什么问题吗
C++含有指针成员的类scoped lock的问题
python没有first class function吧?lambda到底有什么好?
Python为啥Lexical Scoping不适用于import?Help!! variable scope ????
Javascript的Scope问题请教C数组定义问题
some C++ interview questionsperl question
相关话题的讨论汇总
话题: scope话题: closure话题: class话题: function话题: c++
进入Programming版参与讨论
1 (共1页)
m**u
发帖数: 541
1
。。。
用来写大一点的咚咚恐怕不是很放心阿。
l**********n
发帖数: 8443
2
又来了

【在 m**u 的大作中提到】
: 。。。
: 用来写大一点的咚咚恐怕不是很放心阿。

m********s
发帖数: 55301
3
挣钱是硬道理。
工具,不过是实现硬道理的工具。

【在 m**u 的大作中提到】
: 。。。
: 用来写大一点的咚咚恐怕不是很放心阿。

m**u
发帖数: 541
4
这不是有个重要的决定要做嘛,玩大乐到时候要推倒重来不就要命了?
测试了一下,发现不少开发人员使用这玩艺的都不是很靠谱。潜在的隐含风险狠高
有用javascritp做过大项目的给点建议,用javascript写大咚咚行么?
l**********n
发帖数: 8443
5
你干脆直说JS没有class得了

【在 m**u 的大作中提到】
: 这不是有个重要的决定要做嘛,玩大乐到时候要推倒重来不就要命了?
: 测试了一下,发现不少开发人员使用这玩艺的都不是很靠谱。潜在的隐含风险狠高
: 有用javascritp做过大项目的给点建议,用javascript写大咚咚行么?

l**********n
发帖数: 8443
6
你说JS为什么没有class啊,class还是有用的吗。既然function是first class object
,class也可以是first class object啊。

【在 l**********n 的大作中提到】
: 你干脆直说JS没有class得了
l**********n
发帖数: 8443
7
可能是没必要。要定义个class也是分分钟的事情。

object

【在 l**********n 的大作中提到】
: 你说JS为什么没有class啊,class还是有用的吗。既然function是first class object
: ,class也可以是first class object啊。

p*****2
发帖数: 21240
8
js要支持class了这个决定很sb

【在 l**********n 的大作中提到】
: 可能是没必要。要定义个class也是分分钟的事情。
:
: object

p*****2
发帖数: 21240
9
有npm没啥问题

【在 m**u 的大作中提到】
: 。。。
: 用来写大一点的咚咚恐怕不是很放心阿。

l**********n
发帖数: 8443
10
我当初看JavaScript design pattern,就觉得这语言怎么没class。后来想没有class
是为了省事。有时简单的model就够了。class太严谨了。你要玩大的,自己去定义
class,有很多库可以帮你这个。这个语言就是灵活。灵活是第一位的。

【在 p*****2 的大作中提到】
: js要支持class了这个决定很sb
相关主题
Python为啥Lexical Scoping不适用于import?C语言重复定义问题
Javascript的Scope问题很大的C++程序怎么去读啊?
some C++ interview questions请问这个C++程序有什么问题吗
进入Programming版参与讨论
p*****2
发帖数: 21240
11
you got it

class

【在 l**********n 的大作中提到】
: 我当初看JavaScript design pattern,就觉得这语言怎么没class。后来想没有class
: 是为了省事。有时简单的model就够了。class太严谨了。你要玩大的,自己去定义
: class,有很多库可以帮你这个。这个语言就是灵活。灵活是第一位的。

b***e
发帖数: 1419
12
What the fuck are you talking about? JS实现的是标准的lexical scope,也称
static scope:
http://en.wikipedia.org/wiki/Scope_(computer_science)
所有的functional language的scope implementation,凡从lisp那过继来的,都是这
种标准的lexical scope。例如Lisp/Clojure, OCaml, Haskell, etc。C/C++和Java回
避了scope的问题。Pascal是static scope,但是是阉割过的,没有对functional
closure的全支持。初版的ruby才是真正的对scope没想好,closure的实现有问题。
不懂得话可以问,甭他妈胡说八道。

【在 m**u 的大作中提到】
: 。。。
: 用来写大一点的咚咚恐怕不是很放心阿。

l**********n
发帖数: 8443
13
大牛指点迷津。多谢

【在 b***e 的大作中提到】
: What the fuck are you talking about? JS实现的是标准的lexical scope,也称
: static scope:
: http://en.wikipedia.org/wiki/Scope_(computer_science)
: 所有的functional language的scope implementation,凡从lisp那过继来的,都是这
: 种标准的lexical scope。例如Lisp/Clojure, OCaml, Haskell, etc。C/C++和Java回
: 避了scope的问题。Pascal是static scope,但是是阉割过的,没有对functional
: closure的全支持。初版的ruby才是真正的对scope没想好,closure的实现有问题。
: 不懂得话可以问,甭他妈胡说八道。

d*******r
发帖数: 3299
14
"C/C++和Java回避了scope的问题"
是怎么个回避法?像 C++ name space? 大牛展开说说区别呢
我这种从 C++ Python 转去用 JS 的,觉得各种 closure 看着还没有适应

【在 b***e 的大作中提到】
: What the fuck are you talking about? JS实现的是标准的lexical scope,也称
: static scope:
: http://en.wikipedia.org/wiki/Scope_(computer_science)
: 所有的functional language的scope implementation,凡从lisp那过继来的,都是这
: 种标准的lexical scope。例如Lisp/Clojure, OCaml, Haskell, etc。C/C++和Java回
: 避了scope的问题。Pascal是static scope,但是是阉割过的,没有对functional
: closure的全支持。初版的ruby才是真正的对scope没想好,closure的实现有问题。
: 不懂得话可以问,甭他妈胡说八道。

b***e
发帖数: 1419
15
C++ and Java don't allow nested function definitions, and thus does not
support variable scope at all. Yes, there are local scope definition like
in a for loop, but that's not the broad-sense definition/understanding of
variable scoping.
Closure if in fact not hard to understand, if you grab a good mind model. A
closure is the record that contains two fields:
1. code: a function pointer
2. scope: a heap object that maps variable names to pointers of further heap
objects.
When executing a closure, the code referred by the function pointer is
executed and any variable lookup first goes to the stack and then falls back
to the scope that's carried with the closure. That's why it is called a
closure: the scope closes up all the variables referred in the code
for its standing-alone execution.

【在 d*******r 的大作中提到】
: "C/C++和Java回避了scope的问题"
: 是怎么个回避法?像 C++ name space? 大牛展开说说区别呢
: 我这种从 C++ Python 转去用 JS 的,觉得各种 closure 看着还没有适应

l**********n
发帖数: 8443
16
这个说得很清楚

A
heap

【在 b***e 的大作中提到】
: C++ and Java don't allow nested function definitions, and thus does not
: support variable scope at all. Yes, there are local scope definition like
: in a for loop, but that's not the broad-sense definition/understanding of
: variable scoping.
: Closure if in fact not hard to understand, if you grab a good mind model. A
: closure is the record that contains two fields:
: 1. code: a function pointer
: 2. scope: a heap object that maps variable names to pointers of further heap
: objects.
: When executing a closure, the code referred by the function pointer is

n*****u
发帖数: 465
17
三层的 nested function, 第三层能记住第一层(最外面)的吗?

A
heap

【在 b***e 的大作中提到】
: C++ and Java don't allow nested function definitions, and thus does not
: support variable scope at all. Yes, there are local scope definition like
: in a for loop, but that's not the broad-sense definition/understanding of
: variable scoping.
: Closure if in fact not hard to understand, if you grab a good mind model. A
: closure is the record that contains two fields:
: 1. code: a function pointer
: 2. scope: a heap object that maps variable names to pointers of further heap
: objects.
: When executing a closure, the code referred by the function pointer is

p*****2
发帖数: 21240
18

为什么不能呀?

【在 n*****u 的大作中提到】
: 三层的 nested function, 第三层能记住第一层(最外面)的吗?
:
: A
: heap

b***e
发帖数: 1419
19
Yes, it can. The difference between full-fledged static scope and Pascal
like static scope is on whether function (closure) is a first class value
that can be returned as function results and passed into functions as
arguments.

【在 n*****u 的大作中提到】
: 三层的 nested function, 第三层能记住第一层(最外面)的吗?
:
: A
: heap

n*****u
发帖数: 465
20
学习了。大牛再简单介绍一下 prototype 吧,和 __proto__ 的区分。 网上的帖子越
看越复杂。

【在 b***e 的大作中提到】
: Yes, it can. The difference between full-fledged static scope and Pascal
: like static scope is on whether function (closure) is a first class value
: that can be returned as function results and passed into functions as
: arguments.

c*******9
发帖数: 9032
21
我见过银行的javascript项目最后没人敢接手。
pm 被骂的狗血还开不了他。

【在 m**u 的大作中提到】
: 这不是有个重要的决定要做嘛,玩大乐到时候要推倒重来不就要命了?
: 测试了一下,发现不少开发人员使用这玩艺的都不是很靠谱。潜在的隐含风险狠高
: 有用javascritp做过大项目的给点建议,用javascript写大咚咚行么?

1 (共1页)
进入Programming版参与讨论
相关主题
perl questionpython没有first class function吧?
IDL一问Python为啥Lexical Scoping不适用于import?
谁熟dotnet 的webservice?Javascript的Scope问题
[合集] 请教: 模板类之继承的一个小问题some C++ interview questions
FP有的,Python都有!C语言重复定义问题
看了这篇文章关于Javascript Closure就醍醐灌顶了很大的C++程序怎么去读啊?
python的scope机制 非常垃圾请问这个C++程序有什么问题吗
C++含有指针成员的类scoped lock的问题
相关话题的讨论汇总
话题: scope话题: closure话题: class话题: function话题: c++