I have decided that it'd be a bad idea to try to shoehorn my exciting new packaging system into Rol, so I will design (and *gasp* maybe even implement) my own language to use it with
presenting: Rabbit! Python, but Betterâ„¢
here's a sneak peek:
public class HelloRabbit:
public static function main() -> int:
print("Hello, Rabbit!")
i'd also add that there are cases where long-term omitting a signature for a named function is reasonable or even desirable specifically when you already would have to know it--i.e. typeclass/interface implementations and possibly entry points
Simultaneously solve N-queens and no-3-in-line
fastest-codechessgrid
An intriguing MathsSE question asked if there were large N-Queens solutions where no three queens lie on a line. That question's body included the unique 4×4 solution up to symmetries
. Q . .
. . . Q
Q . . .
. . Q .
and noted t...
Your honour, the defendant is clearly breaking all holy laws of functional programming and should be found liable for causing trauma and cringe to all who saw the snippet
Where is the hard part you ask?
Well just follow the rules... :)
Rules:
You can use every language you want
Every instruction has to help you print out hello world
You can only use 3 Math operands in total
You can only use 3 variables in total
All variable names should be exactly 1 byte long
Var...
Hello we all know that $$\sqrt {a^2}=|a|$$ so when we have $$a^2=5$$ that is $$|a|=\sqrt5$$ and $$a=\pm\sqrt5$$ but i very often see that when solving integrals only the positive value is usually considered, for eg.
Here in this example since $$a^2=5$$ that means$$a=\pm\sqrt5$$ but the book cons...
@mousetail yeah, I'm also taking inspiration from Rust
okay, so I think I've figured out exactly how Rabbit's packaging system will work (cc @RydwolfPrograms)
basically, "repositories", which are module sources, can give modules to "libraries", which are module sinks, which can then "lend" modules to programs
it's hard to explain in words, so how about an example
suppose I have a bundle for a program called goat_recognizer
this bundle contains the goat_recognizer module, as well as a dependency (fancy_terminal)
the bundle also has a dynamic dependency (image_recognizer) which the creator of goat_recognizer has deemed too large to be bundled with the rest of the code
bundles are a form of repository according to the packager, so it looks at the file and sees that it's a repository containing one version each of goat_recognizer and fancy_terminal, with goat_recognizer being marked as a "main" module (which means the packager will try to install it)
so the packager adds the bundle to its repository list for this operation
then, it checks the dependencies. It needs to install goat_recognizer, fancy_terminal, and image_recognizer, so it looks at all of its repositories for those packages
goat_recognizer is only available in one repository: the bundle, fancy_terminal is available in both the bundle and a remote repository, and image_recognizer is only available in the remote repository
the packager will then install goat_recognizer from the bundle, download and install image_recognizer from the remote repository, and install fancy_terminal from whichever source supplies a newer compatible version (defaulting to the bundle's copy)
now, I have to think about how the next part will work
gimme a sec
ok got it
so all of these modules are now installed in the global library of modules, and can be run from there
now suppose I want to set up a development environment with my own code
a big feature of the Rabbit interpreter is that it can take a path to a library as input (defaulting to the global library) and it will only import modules from that library
this is mainly useful for setting up a development environment
so now if I make a development environment, a new library is created by the build tools in my work folder, and all of my dependencies are symlinked in
(remember "library" in this context refers to a collection of modules, not a module itself)
it's kinda like the older "module group" system, but less redundant
a big feature of the Rabbit interpreter is that it can take a path to a library as input (defaulting to the global library) and it will only import modules from that library
oh I just had an awful idea: newer versions of packages (since multiple can be installed at once) are diff files between the older package and the newer one
So to make sure I understand this. Rabbit's package manager is called carrot. Carrot's a normal package manager, it just installs a module, then recursively installs its dependencies. A Rabbit program can be packaged into a single bundle containing all of its code and dependency modules, which is how you'd share the program with end user. Some modules can be dynamically linked, which would mean they're installed independently and shared between multiple programs.
Nothing depends on main, so the compiler doesn't care whether it's ! or () if it doesn't terminate. If it does terminate, ! is actually wrong, unlike () for an infinite loop, which is valid but bad practice.
My main point is that the expression [x for i in 1..] should return ! and whatever comes afterwards doesn't matter to the type checker since it can't ever be called
actually, I'm considering making it so that Rabbit programs are "pseudo-built", Python-style, into a kind of optimized bytecode that can then be run by the interpreter
Yea in this case the type checker should ignore the lack of a return statement because the function can never exit. All valid code paths, which is none of them, return a value