These are old notes from the earlier Mythryl 6.0.0 and have not been updated since then.
- TODO: When describing conventions and alternatives, go over the missing
{and};when only doing one thing in the function. I personally would keep them everywhere for this tutorial. - TODO: For loops. If explicit looping actually comes up while programming simple stuff, then it’ll need to be in this beginner’s tutorial.
-
These are unnecessary for a beginner but should be taught later/eventually
stuff ∞
indenting code ∞
Perhaps two spaces is enough of an indent for you. Maybe three is more pleasant. Whichever you choose, generally stick with it but it is perfectly fine for you to decide on more or less spaces, in order to make any specific case more readable.
Do not sacrifice readability to convention. Not ever.
Do not fret over:
-
The extra spaces “making your program bigger”.
- Disk space is cheap compared to wasted time with awkward comments.
-
The extra time it takes to “make everything pretty”.
- The time you take to write your comments well and format them clearly is time you and everyone else reading your code in the future won’t have to spend again and again.
For me, I’m (hopefully) “in the zone” when programming, and I worry that the change in mindset from programming to formatting may disrupt my flow. In practise this doesn’t seem to really matter, and I even benefit from these small breaks.
boolean ∞
TODO: I don’t understand this at the moment
eval: foo = { tall => TRUE, dark => FALSE, handsome => FALSE };
{ dark=FALSE, handsome=FALSE, tall=TRUE }
eval: printf "Foo: { tall => %b, dark => %b, handsome => %b };\n" foo.tall foo.dark foo.handsome;
Foo: { tall => true, dark => false, handsome => false };
De-bugging your output ∞
When using printf to output some text, it’s a good practice to surround your percent-thingy (TODO: Name) with quotes. This lets you see, for example, if you have beginning or trailing spaces.
- TODO: A decent real-world example is needed. I can’t think of anything off the top of my head!
-
TODO: Is there a way to “reveal” escape codes? Ruby has .inspect to show things like
\n
stuff ∞
-
show_vals();— lists pervasive values- … which are available without opening a package, and most of those are functions. More generally, all of the functions in the standard library are usually available.
show_pkgs();— list all packages,-
show_api();— list all apis- This doesn’t work for me.
-
show_api "foo"— A detailed listing of the contents of any given api.- (You can also refer to the detailed indices of functions etc on the mythryl.org website.) (TODO: Find them)
other arithmetic ∞
TODO: I’m not sure how to work with these yet:
|(pipe) — inclusive or-
^(carat) — exclusive or
These are used just like + or - would be.
Cynbe says:
Exclusive or is just addition without carry. It has the neat property if you do
x = a^b;then
x^a == band
x^b == awhich winds up getting used a lot in cryptography.
The logic ops make a lot more sense if you know your
hex <-> binaryconversions cold, so that when you read ‘5’ you see ‘101’ without conscious effort. :-) Once you reach that point, you know automatically that 6&5 will be 4 etc.
functions which throw runtime exceptions ∞
Cynbe says:
Functions which throw runtime exceptions are really, really good things to avoid like the plague any time you possibly can.
