08:59 | <Jack Works> | Is it possible to freeze the [[Prototype]] of an ordinary object without wrapping it with Proxy? |
10:13 | <Ashley Claymore> | Nope. Can only make it non-extensible. Props and prototype all part of the same bag |
10:40 | <Ashley Claymore> | https://github.com/tc39/proposal-freeze-prototype |
10:42 | <Ashley Claymore> | https://matrixlogs.bakkot.com/TC39_Delegates/2021-09-20#L1 |
15:30 | <nicolo-ribaudo> | Is there an es5 way of creating a function with length n (where n is known statically when I'm writing the code), and for which IsConstructor returns false ? |
15:51 | <jmdyck> | As far as I can tell, in es5, the only functions that don't have a [[Construct]] internal method are all built-ins. So even without the length constraint, the answer looks like no. |
16:11 | <nicolo-ribaudo> | Ok thanks, that matches what I expected but I was hoping for secret hacks 😂 I know that I can create functions with length 0 and 1 using getters and setters in object literals, but it does not generalize to 2+ args. |
18:19 | <ljharb> | those functions are constructors tho, aren't they? |
18:24 | <nicolo-ribaudo> | Nope:
|
18:26 | <littledan> | yeah, all concise methods, e.g., new ({x() {}}.x) |
18:26 | <littledan> | and arrow functions |
18:44 | <jmdyck> | Are you running that in an ES5 engine? |
18:45 | <littledan> | I am saying, those things are not constructors, and that code throws. I am using a new engine |
18:46 | <jmdyck> | and nicolo-ribaudo ? |
18:46 | <littledan> | oh sorry I missed the "es5" part of the question! |
18:47 | <jmdyck> | looks like semantics changed between es5 and es6 |
18:56 | <Ashley Claymore> | Does that work in ES5? alt: Using a getter, but re defining length and accessing args via arguments |
18:56 | <Ashley Claymore> | or is it a valid constructor in es5? |
19:02 | <nicolo-ribaudo> | No, I only tested it in modern browsers. Thank you! |
19:04 | <nicolo-ribaudo> | For context, I was trying to figure out how to compile arrow functions to es5 in a 100% spec compliant way (mostly for fun, I'm not going to add this to Babel) |
19:05 | <nicolo-ribaudo> | sent an image. |
19:07 | <jmdyck> | In ES5, get PropertyName etc involves "the result of creating a new Function object as specified in 13.2", which always sets both [[Call]] and [[Construct]]. |
19:07 | <jmdyck> | In ES6, it involves "FunctionCreate(~Method~, ...)", which leads to FunctionAllocate being called with _functionKind_ = "non-constructor", which causes [[Construct]] to not be set. |