Confusing use of val and ref in Object Literals section on lambdas
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 35/100
- Tipo di issue
- Documentazione
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Ambito
- documentation
Direzione di ricerca
Start in the Object Literals section and find the reduce function example that discusses val and ref lambda objects. Compare it with the Capabilities chapter, then revise the explanation to use a box lambda parameter and link readers forward; done means the relationship between val, ref, and box is clear.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
A lambda object is always returned as val if it does not close over any other variables. If it does capture values from the lexical scope then it is returned as a ref. The reference capability in the type declaration can be supplied by adding it before the closing curly bracket. If it is not provided it defaults to ref. The following is an example of a val lambda object:
I found this paragraph very confusing, and even after re-reading it I couldn't figure out why val and ref would be mutually incompatible. The answer came later in the Capabilities chapter; I had been thinking of val acting more like box (or like const in C++), so I didn't understand why you couldn't pass a ref reference to a val parameter.
I'd suggest you simplify this example by declaring the reduce function's lambda parameter as box, and then just glossing over that by saying it allows either a val or a ref to be passed to it, and linking ahead to the Capabilities chapter.
- Lingua principale
- Markdown
- Stelle
- 367
- Fork
- 112
- Merge medio
- 3g 3h
- PR unite (30g)
- 10
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di ponylang/pony-tutorial
-
[4/?] Add ability to run code examples in the playground: Get pony snippets tested with ponyc at CI timeForse già presa @shaedrich l’ha presa 851 giorni fa. Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
ponylang/pony-tutorial#549 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
The header title …Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
ponylang/pony-tutorial#547 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 48/100
ponylang/pony-tutorial#526 ·
I maintainer di solito rispondono entro 1 giorno
-
help wanted
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 48/100
ponylang/pony-tutorial#495 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 45/100
ponylang/pony-tutorial#491 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di ponylang/pony-tutorial
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
inu-appcenter/memorIN-frontend#106 ·
I maintainer di solito rispondono entro 1 giorno
-
workflow: a tick's dispatch counts as 'only this step', and no review self-grants a round unattendedApertaworkflow
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
kristofdegrave/homeassistant-smart-charging#1505 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
openfoodfacts/score-my-recipe#80 ·
I maintainer di solito rispondono entro 2 giorni
-
documentation
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
githubnext/gh-aw-workshop#3968 ·
I maintainer di solito rispondono entro 1 giorno