これは、Rubyに仮想的なトップレベル名前空間を導入するためのNamespaceを提案します。NamespaceはRubyスクリプトかネイティブ拡張ライブラリかを問わず、ライブラリをグローバル名前空間から独立した形でrequire/loadします。
"Namespace on read"は次の2つの問題を解決し、また1つの問題について解決の道筋を提供します。
- ライブラリ(等)間での名前の衝突を避ける
- グローバルに共有されたライブラリ/オブジェクトの意図しない変更を避ける
#!/bin/bash | |
SCRIPTNAME=$(basename "$0") | |
function realpath () { | |
f=$@; | |
if [ -d "$f" ]; then | |
base=""; | |
dir="$f"; | |
else | |
base="/$(basename "$f")"; |
// when T is any|unknown, Y is returned, otherwise N | |
type IsAnyUnknown<T, Y, N> = unknown extends T ? Y : N; | |
// when T is never, Y is returned, otherwise N | |
type IsNever<T, Y = true, N = false> = [T] extends [never] ? Y : N; | |
// when T is a tuple, Y is returned, otherwise N | |
// valid tuples = [string], [string, boolean], | |
// invalid tuples = [], string[], (string | number)[] |
Memoization is a somewhat fraught topic in the React world, meaning that it's easy to go wrong with it, for example, by [making memo()
do nothing][memo-pitfall] by passing in children to a component. The general advice is to avoid memoization until the profiler tells you to optimize, but not all use cases are general, and even in the general use case you can find tricky nuances.
Discussing this topic requires some groundwork about the technical terms, and I'm placing these in once place so that it's easy to skim and skip over:
2020/5/31追記:
自分用のメモに書いていたつもりだったのですが、たくさんのスターを頂けてとても嬉しいです。
と同時に、書きかけで中途半端な状態のドキュメントをご覧いただくことになっており、大変心苦しく思っています。
このドキュメントを完成させるために、今後以下のような更新を予定しています。
2021/1/22追記:
{ | |
"version": "0.2.0", | |
"configurations": [ | |
{ | |
"name": "Example", | |
"type": "node", | |
"request": "launch", | |
"runtimeExecutable": "node", | |
"runtimeArgs": ["--nolazy", "-r", "ts-node/register/transpile-only"], |
Note: I'm not involved in Prepack in any way — please correct me if I say anything incorrect below!
A few people have asked me if Prepack and Svelte are similar projects with similar goals. The answer is 'no, they're not', but let's take a moment to explore why.
Prepack describes itself as a 'partial evaluator for JavaScript'. What that means is that it will run your code in a specialised interpreter that, rather than having some effect on the world (like printing a message to the console), will track the effects that would have happened and express them more directly.
So for example if you give it this code...
// jsonschema | |
export type JSONSchema$Type$Base = { | |
id?: string, | |
required?: boolean | |
} | |
export type JSONSchema$Type$Object = JSONSchema$Type$Base & { | |
type: 'object', | |
properties: {[key: string]: JSONSchema$Type}, | |
additionalProperties?: false, |