You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In node the file-system operations are by default asynchronous. Some file operations allow for synchronous operation, blocking the code, obviously. This is explicitly defined by labeling synchronous functions by appending 'Sync' to the function name. Labeling a function 'Sync' is highly advantageous because it shows the programmer that this is a blocking function.
Bonescript goes against this convention. It overloads read/write operations to perform both sync and async, depending on weather a callback was supplied. I suggest splitting this out. There are two ways of doing this, the non-breaking way and the breaking way.
I would be glad to implement these changes, but I would need your okay with how to continue.
Option 1: breaking
This option would break existing implementations using bonescript. But it would make using bonescript clearer, since sync functions would be labeled and the programmer would know if the function is blocking or not.
Features:
Add a warning message (or error) to all dual-purpose functions, that it is now asynchronous.
Create a sync function for each dual-purpose function.
The old function would not return a valid value for a Sync operation.
Example: analogRead(pin, [callback]) -> value would become analogRead(pin, callback) (always returns undefined) and a new function would be created like: analogReadSync(pin) -> value.
Option 2: non-breaking
This option would be non-breaking, but we could add a message for users for them to migrate to option 1.
Features:
Keeps the existing function as-is.
Add a warning message to all dual-purpose functions, that it is now asynchronous.
Create a sync and async function for each dual-purpose function.
Provides a possible migration path to option 1.
Example: analogRead(pin, [callback]) -> value remains, but when called, it is suggested to use one . The following two functions are added:
new function: analogReadAsync(pin, callback).
new function: analogReadSync(pin) -> value.
The text was updated successfully, but these errors were encountered:
In node the file-system operations are by default asynchronous. Some file operations allow for synchronous operation, blocking the code, obviously. This is explicitly defined by labeling synchronous functions by appending 'Sync' to the function name. Labeling a function 'Sync' is highly advantageous because it shows the programmer that this is a blocking function.
Bonescript goes against this convention. It overloads read/write operations to perform both sync and async, depending on weather a callback was supplied. I suggest splitting this out. There are two ways of doing this, the non-breaking way and the breaking way.
I would be glad to implement these changes, but I would need your okay with how to continue.
Option 1: breaking
This option would break existing implementations using bonescript. But it would make using bonescript clearer, since sync functions would be labeled and the programmer would know if the function is blocking or not.
Features:
Example:
analogRead(pin, [callback]) -> value
would becomeanalogRead(pin, callback)
(always returns undefined) and a new function would be created like:analogReadSync(pin) -> value
.Option 2: non-breaking
This option would be non-breaking, but we could add a message for users for them to migrate to option 1.
Features:
Example:
analogRead(pin, [callback]) -> value
remains, but when called, it is suggested to use one . The following two functions are added:analogReadAsync(pin, callback)
.analogReadSync(pin) -> value
.The text was updated successfully, but these errors were encountered: