-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[ANNOUNCEMENT] Import stmt added; Recruiting Std lib implementers! #290
Comments
I can help with That would be non-trivial amount of work though, as doing floating point math right is hard. (Even the current implementation of |
Hi @statementreply That would be very much appreciated! Take your time, we all know it's hard ;) |
@LingDong-
Btw, |
@statementreply Oops. Didn't think carefully about negative numbers. Should be an easy fix.
But apparently Therefore a more robust algorithm is needed, at least for very large numbers. |
I can help with list operation ("列經"?). Having array slicing and collection operations would be nice. Also, having some built in data structures would be awesome. As I mentioned in #326 , I have general concern on how much we introduce Javascript dependencies in Std implementations. Would love to have more input on this issue from folks. |
Hi @liaocm, thanks so much for your interest! For ndarrays, I'm planning to port (rewrite) one of my own libraries, 洛書 https://github.com/LingDong-/Loshu.js to wenyan-lang. It is a JS linear algebra library (complete with matrix decompositions and other advanced stuff). Since it is purely written in plain JavaScript. It should be easy to rewrite in wenyan. If you would like to help, please feel free to take a look at that repo and start translating some of the functions. Thank you very much! Regarding #326, I think there is a big misunderstanding. The goal IS to implement everything in WENYAN, not in JavaScript. The current code in these standard library files are temporary. They're there just so that an implementer know what the function is supposed to do, and if another function they're implementing depends on this function, they can use it assuming it works, facilitating testing and modularity. Thanks! |
@LingDong- - thanks for the clarification. It makes sense that we shouldn't have dependencies on a specific trans-piled language. For bitwise ops I think it makes more sense to support those as built in operators though - simulating them with math tricks seems to be awful inefficient. |
Alternatively, we could define compiler intrinsic functions or platform API functions for things like bit-wise operations (low-level) and getting current date & time (impossible to implement). When the code says |
@statementreply sounds neat! I've been pondering how to integrate platform specific stuff like time/GUI/bits, and yours sounds like a good solution. Thanks! @liaocm Please feel free to add 列經 as you see fit. Sorry I was still thinking about the ndarrays mentioned in another thread yesterday, and now it comes to my realization that you're talking about Arrays, like slice, find, join, pop etc. So yeah that would be very much appreciated. Thanks! |
Hello everybody! I just implemented the import statement, which allows standard library to be added for the language. You think you can write wenyan? Help build the standard library for wenyan! See below for details:
1. Import statement (experimental)
Below is the new import syntax. Thanks everyone for the inspiration!
New usage of
今有
.今有
is now used for exported/public variables, while吾有
is private/scoped. Think of今有
likemodule.exports.x=
. Think of吾有
likevar x=
Example:
易經.wy
(a.k.a. Random)some_example.wy
(where you import random)Notice that in
易經.wy
the random seed (運數) is not exported. while its setter (運) is exported, but not imported bysome_example.wy
. Only占
the generator is exported and imported, and can be used directly.JS implementation details
(Python, Ruby are not implemented yet)
JS Implementation uses
var MODULE_NAME = new function(){ ... }
trick to wrap imported modules.今有
maps tothis.
So they can be accessed usingMOUDLE_NAME.identifier
. The import statements specifies which identifiers are actually required, and those that are are extracted from its scope usingvar identifier = MODULE_NAME.identifier
. Therefore,some_example.wy
compiles to this:You can check out a more sophisticated example on the online IDE. In the IDE, you can import an example from another example, or the a module from standard lib.
parser.compiler
has a new option calledreader
, which is a function you can provide to tell compiler how to read a module. The default for node.js is to look in current directory plus one directory down. For browser-side you might give it something fancy like AJAX calls or something.When you build the CLI compiler, the source of the standard libraries are included, so you can still use it without having the
./lib
folder.Please let me know if found any issue or have any suggestion!
2. Standard Library implementers needed!
You think you can write wenyan? Please join us!
Currently in the
./lib
folder there are a couple of "stubs" such as算經
(math)位經
(bit ops)易經
(random).They contain many functions to be implemented in wenyan. e.g. The
sin()
function currently contains this HACK:What we need to do is to replace
Math.sin
hack to a proper implementation (Taylor series?).Our goal is to implement the most commonly used library functions. If you are familiar with one or two of them, please submit a pull request!
3. Thanks!!
As you might have noticed, much of the syntax and many ideas are inspired by / borrowed from numerous posts and feature requests. Therefore, a thank you to everyone!
The text was updated successfully, but these errors were encountered: