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

Custom built-in functions #100

Open
NatanFreeman opened this issue Sep 22, 2022 · 8 comments
Open

Custom built-in functions #100

NatanFreeman opened this issue Sep 22, 2022 · 8 comments

Comments

@NatanFreeman
Copy link

I would like to define custom built in functions from Rust call-backs. This makes the functions more extendable as you have access to Rust's functionality like println! along with other Rust math libraries. Is this currently possible? If not I think this should be considered. It allows fore greater extendibility without the need of another parser.

@PaddiM8
Copy link
Owner

PaddiM8 commented Sep 23, 2022

I've been thinking about implementing some way to have custom built-in functions. This sounds like a good way to do it. Would love to implement this at some point.

@Yusuto
Copy link

Yusuto commented Oct 27, 2022

This would be something that would need to be implemented in the kalk crate, right?
I am very new to all of this, but this seems somewhat straightforward, would I be allowed to try to implement this?

@PaddiM8
Copy link
Owner

PaddiM8 commented Oct 29, 2022

@Yusuto Correct, that would be done in kalk. Feel free to give it a try! Function calls are evaluated in interpreter.rs#L330.

@Yusuto
Copy link

Yusuto commented Nov 5, 2022

@PaddiM8 Okai, Thank you! I looked around a bit and this stuff seems to be significantly more complex that I first imagined. In hindsight it makes sense, since it's in essence somewhat of a tiny programming language ><
Am I correct in that kalk as of now has pretty much no documentation? If so I could offer to write some rustdoc as I go about understanding everything, if that is desired!

@PaddiM8
Copy link
Owner

PaddiM8 commented Nov 5, 2022

@Yusuto Yeah it basically turned into a small languages, woops. You're right, it does lack documentation. That would be great!

@Yusuto
Copy link

Yusuto commented Nov 5, 2022

Yep! I think it's actually quite interesting and sounds pretty powerful, it's sadly not Wolfram Alpha, but I have come to use kalker as my day-to-day calculator to the point where I aliased it to just k in my shell.

I have very little experience with that, but it seems like it could be turned into a good PWA? I'd very thrilled to have a proper calculator on my phone, not sure if that's just me but it seems like all the alternatives are just kind of- ugly. I mean they do their job but not really much more. And kalker already works quite decently in a mobile browser, so ^^

I saw some project files for Android, I suppose a native app would be even better, you could maybe even have things such as a widget for quickly calculating or something, that sounds convenient

@PaddiM8
Copy link
Owner

PaddiM8 commented Nov 5, 2022

@Yusuto It's great to hear that you're finding it useful! There is an apk for Android that basically just loads it as a website, but works quite well for me at least. A PWA would be a good solution for iPhones actually, didn't think of that.

@Yusuto
Copy link

Yusuto commented Nov 5, 2022

@PaddiM8 Yep! they even support stuff like Push-Notifications using Service Workers, and if you have a modern browser that allows you install a PWA, I think they are even guaranteed by the browser to work without an internet connection (provided the devs didn't mess something up).

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

3 participants