Skip to content
This repository has been archived by the owner on Sep 22, 2021. It is now read-only.

Remove constructor #29

Closed
dy opened this issue Oct 3, 2018 · 3 comments
Closed

Remove constructor #29

dy opened this issue Oct 3, 2018 · 3 comments

Comments

@dy
Copy link
Member

dy commented Oct 3, 2018

Constructing a function is unreasonable:

let sine = generate.sine({frequency: 1000})
sine(1024)
sine(1024, {frequency: 2000})
  • we still keep options argument for "changing state"
  • "live" options take all the same properties as constructor options
  • that is hard to remember routine, empirically.

More natural is to have instant signature as generate.<what>(<how much>, <how?>):

let result = generate.sine(1024, {frequency: 1000})
generate.sine(1024, {frequency: 2000, phase: result.phase })

That also allows for reducing difficult audio-through dependency.

@dy
Copy link
Member Author

dy commented Nov 27, 2018

Another optimizations:

  • no need for a-rate params as functions - that is done via direct options; that slows down massive generation
  • no need for syntax sugar: complicates generation whereas benefit is tiny

@dy
Copy link
Member Author

dy commented Nov 27, 2018

Ways to persist state?

  1. Provide properties on the output array. That forbids deepEqual and not well established pattern, although pretty handy. Does not allow to generate a sequence of linked arrays.
  2. Keep internal weakmap cache of per-instance states. Does not allow to generate a sequence of linked arrays.
  3. Use global state - generates a sequence of arrays.

@dy
Copy link
Member Author

dy commented Nov 28, 2018

Done in 3.0.1.
Explicitly persisted state is better than implicit.

@dy dy closed this as completed Nov 28, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant