Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core] Add new using function #1824

Closed
drkameleon opened this issue Dec 12, 2024 · 1 comment · Fixed by #1842
Closed

[Core] Add new using function #1824

drkameleon opened this issue Dec 12, 2024 · 1 comment · Fixed by #1842
Assignees
Labels
→ Core enhancement New feature or request new feature New feature/addition

Comments

@drkameleon
Copy link
Collaborator

Right now, we have with which basically creates a new block by encapsulating a given variable/value (very useful in a "closure" context).

What using would do is something similar-ish, but:

  • safer
  • totally scoped
  • more specific
  • centered around this

Also, using as a name is used in very similar contexts in other languages... So...

In short: the idea is to... introduce a forced this (and restore the previous one, if there), so that we can use field \shortcuts.
As similar idea is Nim's own with: https://nim-lang.org/docs/with.html#with.m%2Ctyped%2Cvarargs%5Buntyped%5D

And, yes, it's more than just a simple coincidence... lol (👀 #1731)

Example:

; before
window\size: [300, 400]
window\center
window\title: "New window"

; after
using window [
    \size: [300, 400]
    \center
    \title: "New window"
]
@drkameleon drkameleon added enhancement New feature or request new feature New feature/addition → Core labels Dec 12, 2024
@drkameleon drkameleon self-assigned this Dec 12, 2024
@RickBarretto
Copy link
Collaborator

RickBarretto commented Dec 14, 2024

What a great addition!
This would improve the readability and workflow. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
→ Core enhancement New feature or request new feature New feature/addition
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants