Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Confusing use of val and ref in Object Literals section on lambdas

Aperta
#129 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

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

good first issue help wanted

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

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di ponylang/pony-tutorial

Tutte le issue di ponylang/pony-tutorial

Issue simili

Altre issue su Documentation

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.