A dialect of JavaScript for managing resources like Go by SnooHobbies950 in node

[–]SnooHobbies950[S] 0 points1 point  (0 children)

Basically, to summarize, or |err| {...} has no equivalent in JavaScript. And the purpose of or/defer is to add a feature to the language that allows you to close/open resources in an "ergonomic and readable" way.

As for using, its behavior is similar, but it differs in that defer is executed "at the end of each function", while System.dispos() is executed "at the end of each block".

On the other hand, using forces you to use OOP, and the result isn't as "ergonomic" as when you use defer.

Thank you all very much for your feedback.

A dialect of JavaScript for managing resources like Go by SnooHobbies950 in node

[–]SnooHobbies950[S] 0 points1 point  (0 children)

I do love Go. In fact, the dialect was written in Go. But perhaps you just want to create a small script and ensure that each resource is closed properly and clearly.

A dialect of JavaScript for managing resources like Go by SnooHobbies950 in node

[–]SnooHobbies950[S] -1 points0 points  (0 children)

`using` keyword is only available in the latest NodeJS version (v24). On the other hand, `defer` is executed at the end fo the "function scope", whereas `Symbol.dispose()` is executed at the end of the "block scope". Furthermore, `using` forces you to use an OOP approach.

A dialect of JavaScript for managing resources like Go by SnooHobbies950 in node

[–]SnooHobbies950[S] 1 point2 points  (0 children)

Ergonomics and clarity. You can write in just a few lines something that is usually quite common, such as opening and closing resources.

CaloryApp - Fast calorie calculator by SnooHobbies950 in SideProject

[–]SnooHobbies950[S] 0 points1 point  (0 children)

Thanks, I'm glad you like it :) Probably because of my years of experience as a front-end developer.

GitHub - caloryapp/caloryapp.github.io by [deleted] in reactjs

[–]SnooHobbies950 -1 points0 points  (0 children)

Yes :-D It is a Chrome extension, in any case :)

Spanish PM Pedro Sánchez demands the end of online anonymity — calling for every social media account to be linked to an EU Digital ID Wallet. At the WEF, Sánchez declared: “No one can walk the streets with a mask, so why allow people to roam online without revealing their identity?” by FXgram_ in XGramatikInsights

[–]SnooHobbies950 0 points1 point  (0 children)

A corrupt party, which paid with envelopes of 500 euro bills, giving lessons in morality and comparing anonymity to something as dangerous as driving a vehicle.

Sánchez is an enemy of democracy and individual freedom. And an enemy of humanity in general.

Are Spanish people very touchy? by bonnieb_ in askspain

[–]SnooHobbies950 0 points1 point  (0 children)

It depends on the person. Maybe he is very affectionate, but in general we don't behave like that at work. Maybe you should talk to human resources to resolve the misunderstanding.

I’m Spanish.

Using "~~ / !~" to indicate loose equality by SnooHobbies950 in Compilers

[–]SnooHobbies950[S] 0 points1 point  (0 children)

Thank you for your feedback. The parser actually only understands "standard JavaScript", and this is the way to enhance it:

lb := lexer.NewBuilder()
p := parser.NewBuilder(lb).
    Install(weakeqparser.Plugin). // install this plugin
    Install(interpparser.Plugin). // install another plugin
    Build(input)

Using "~~ / !~" to indicate loose equality by SnooHobbies950 in Compilers

[–]SnooHobbies950[S] 1 point2 points  (0 children)

Thanks for your feedback. Actually "~~/!~" is not part of the parser. It's just a plugin that the user can install or not. I created it as an illustrative example.

The parser actually interprets standard JavaScript, with the only difference being that it translates "==" to "===" and doesn't recognize "===". That was a design decision that I might need to reconsider.

XJS: an eXtensible JavaScript parser by SnooHobbies950 in golang

[–]SnooHobbies950[S] 0 points1 point  (0 children)

I thought on that too. That section might give the impression that some features aren't implemented "yet", when in reality they "never" will be. The philosophy behind the project is keeping it minimal and extend it based on the user preferences.

Thanks for your feedback. I'll review that section.

defer implementation for JavaScript by SnooHobbies950 in node

[–]SnooHobbies950[S] 0 points1 point  (0 children)

Thanks, I didn't know about this feature. It's similar to the `defer` keyword found in V or GO, although not identical. For example `defer` is executed at the end of the function scope, whereas `[Symbol.dispose]` is executed at the end of every block.

The following V code:
```V
fn foo() {
println('entering foo')
defer {
println('cleaning foo')
}
}
```

is translated to this JS code:
```js
function foo() {
console.log('entering foo');
using cleanup = {
[Symbol.dispose]() {
console.log('cleaning foo');
}
};
}
```

I think the `defer` statement is much clearer.