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

Using space character in text #81

Closed
soraxas opened this issue Dec 24, 2021 · 6 comments
Closed

Using space character in text #81

soraxas opened this issue Dec 24, 2021 · 6 comments

Comments

@soraxas
Copy link

soraxas commented Dec 24, 2021

Hi! What would be the best way to input space characters in the macro engine?
For example, to display " HI" as the led text.

@kareltucek
Copy link
Owner

kareltucek commented Dec 24, 2021

Currently there is no way to do that. (Let's call it technical debt.)

At some point, the language definition should be refactored so that strings are unambiguously regex-recognizable tokens (some type of quote notation). This loosely relates to UltimateHackingKeyboard/agent#1630 and its plan to provide syntax-aware editor features - I assume that the refactor may be either necessary, or desirable in order to make those features work.

(Also, during such refactor, other features may be considered - like scoping or expression parser.)

@soraxas
Copy link
Author

soraxas commented Dec 25, 2021

I think it's amazing how this macro engine had implemented such a workable token parsing engine for the macro engine. But indeed it is always cumbersome to reinvent string token parsing. Perhaps we should leverage existing scripting engines (or at least get inspiration on how they are implemented) to avoid re-inventing the wheels?

For example, this lisp interpreter in C looks interesting and it directly follows the operator / args expression that we currently have. The brackets also helps scoping the expression (and chaining actions)

@kareltucek
Copy link
Owner

(or at least get inspiration on how they are implemented) to avoid re-inventing the wheels

This is totally agreed.

Perhaps we should leverage existing scripting engines

Please note that we are very tight on RAM.

UHK has 128 kb of RAM out of which 2x 32 kb are taken by configuration. It might be possible to free one of these regions by some clever refactor. The 64 kb are almost depleted - there are some 3kb of reserve in buffers - and we will probably need to free some of it for custom RGB backlight. I am not sure how good idea it would be to introduce malloc into the codebase - so far, everything is statically allocated, and the macro engine is designed so that it is almost stateless.

For example, this lisp interpreter in C looks interesting and it directly follows the operator / args expression that we currently have. The brackets also helps scoping the expression (and chaining actions)

I will give it more thought another time. However, if you are eager to dig deep into it, feel free to.

@kareltucek
Copy link
Owner

kareltucek commented May 9, 2022

I have looked briefly into the interpreter, and realized that I am not sure how to maintain stateful information if the interpreter is employed.

It seems to me, that either a lot of the logic of "modifier commands" would either have to be re-implemented in lisp and consequently loaded as a lisp library, or a lot of state would have to be maintained outside of the lisp interpreter itself, including scoping.

As a result, it seems like employing the interpreter would mean having to write and maintain an engine which would actually execute as a "Cartesian product" of the current macro engine and the lisp interpreter. I.e., the solution would have to switch between C runtime and lisp interpretation modes in a very intricate and delicate manner.

I have a feeling that lisp, as a pure functional language is well suited for computing results, but badly suited to do effectful processing. In this sense, current macro language is 100% procedural language, which does 100% of its work by performing effects, rather than computing values in a functional sense.

@kareltucek
Copy link
Owner

(This is assuming that we would actually want UHK to run a full fledged lisp interpretter.)

@kareltucek
Copy link
Owner

Is/will be solved by UltimateHackingKeyboard#674

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants