Clarify undefined behavior when target == source in PMatrix::mult docs

Aperta Adatta ai principianti
#1,591 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
1/5
Tempo stimato
Meno di un'ora
Idoneità per principianti
85/100
Tipo di issue
Documentazione
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
java
Ambito
documentation

Direzione di ricerca

Leggi il Javadoc di PMatrix.mult in core/src/processing/core/PMatrix.java, intorno alle righe 165–171. Chiarisci cosa succede quando target e source sono lo stesso oggetto e correggi la formulazione che definisce matrice il valore restituito. Il lavoro è completato quando la documentazione descrive accuratamente il comportamento e identifica il valore restituito come un PVector.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Hi folks!

I know this won't be top priority, but this issue caused me to spin my wheels for a couple days straight since it was one of those times where all my logic "looked right" after many passes so I figured it might throw some other beginners for a loop.

I'd like to request additional clarity be added to the javadoc here:

https://github.com/processing/processing4/blob/cd50e02e5a8cdf41f8bb165b6ebd85feeeeac543/core/src/processing/core/PMatrix.java#L165-L171

Specifically, I think that it should be stated explicitly that behavior is undefined when target == source. Since no warning was offered I did not expect for the contents of source to still be in the process of being read by the time that target is actually being populated within this method but it appears something like that is happening (my expectation was that the contents of source would have probably been extracted into local variables once at the beginning since there are so few elements in a PVector and then loaded into target once at the end after performing intermediate computations). Ideally, if there is no utility in allowing target == source whatsoever, this case should throw an exception but, alternatively, additional doc clarity would have been a noninvasive way of preventing prolonged confusion in my case. Also I think "target will then be the matrix returned" is a typo since this method is returning a PVector.

Here is an example sketch you can use to observe the undocumented undefined behavior. Move the mouse around without pressing anything to observe normal behavior when simply passing target = null. Similarly, pressing Right-click will set target equal to a PVector reference which is fixed across draw() frames--the outcome of which is normal behavior. Pressing Left-click will pass target = source triggering the undefined behavior.

Thanks!

Lingua principale
Java
Stelle
527
Fork
190
Merge medio
1g 4h
PR unite (30g)
3

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 processing/processing4

Tutte le issue di processing/processing4

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.