Advertisement
xanny

Hello World in Al

Dec 23rd, 2012
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.94 KB | None | 0 0
  1. ## This language spec is licencsed under the GPL v3. Contact the FSF for a copy of the license if needed. ##
  2.  
  3. # A single pound is a single line comment. ## would start a multiline comment, except here it is already on
  4. # a single line comment, so it is ignored.
  5.  
  6. #* Pound followed by a glyph character that isn't in the set of whitespace or alphanumerics is a multiline
  7. comment delimiter. The comment ends when the pattern is repeated in inverse. This way you don't need special
  8. escape characters in comments. Since pound itself is a special glyph, ## is a valid delimiter and is my personal preference for quick typing. The delimiter can be any number of special glyphs, so you could have ####### as the delimiter if you wanted. Considerations for non-latin letters and numerials may be needed, because the sets of alphanumerics can be subjective based on alphabet in use. We want non-alphabetic glyph characters to deliminate multiline comments, basically. *#
  9.  
  10. #! This allows a language extension to just mandate that perhaps #! means a doc comment, or someones coding guidelines could use the delimiter to mean certain behaviors. !#
  11.  
  12. ## import is a modular instruction, it uses / as the path delimiter because while it isn't textual inclusion, modules are file system based. Since the whole OS is VFS based, code interactions behave similarly. alias is a simple translation instruction to namespace the predecessor as the successor. The semicolon is only present in the whitespace ignorant language dialect, in whitespace significant syntax the newline would behave in the same capacity. ##
  13.  
  14. import std/io;
  15. std/io/print alias print;
  16.  
  17. ## This is a compiled language, so executed code can not exist outside function definitions since we end up putting this bundle of joy in execution space. We use main() for posterity here, but I'm open to alternative names like entry, start, or begin.
  18.  
  19. Some important facets of this syntax - null is the universal absence value, rather than void. Any circumstance in other languages where you would use one or the other, null will always be the syntactic void declarator.
  20.  
  21. The parameters are specified by type - name, like in most classic languages. The order makes sense imo, being what > who. It is a pretty logical operand order.
  22.  
  23. Classic braces are used here, but you can easily have other delimiting glyphs that don't cause compiler contention. In the whitespace significant version, for example, indention would deliminate this context block.
  24.  
  25. The usage of func is optional, but it is provided here since not only are units of execution first class members of this language, they are also objects, and can be treated much the same as almost any other data type. Under the hood, they only exist in code space and all that is passed around is their references to maintain the data : code boundary
  26.  
  27. The theoretical model of this programming environment wouldn't include a concept as limited as an exit code. In practice, any errors during execution would be reported over an error buffer. ##
  28.  
  29. public func Main(array<string> Args) : null {
  30. print("Hello world\n");
  31. }
  32.  
  33. ## print could be incited as std/io/print() or just print since we aliased it. Since forward slashes are the universal namespace depth tracer, we are using them here. The classic dot syntax could in theory work, but it seems like a disconnect to me to refer to files as what/the/foo but units of exection as foo.the.bar. ##
  34.  
  35. ## Just for posterity, here is the minified version of Hello World. Since we use a module based import system, we can import inline.##
  36.  
  37. import std/io
  38. Main(array<string> Args ) : null { std/io/print("Hello world\n"); }
  39.  
  40. ## Potential syntaxes changes:
  41. 1. Merge import and alias statements in a shorthand a la import std/io/print alias print, even though "print" isn't an importable module itself, but we import the module that contains it and alias the function?
  42.  
  43. 2. Somehow inline module importing so we don't need explicit import statements for once-used methods?
  44.  
  45. 3. Nicer way to define a function? The classic model of prefixing the definition with qualifiers, including the access modifier, the return value, language specific syntax like template declarations, static qualification, extern specification, finality, etc. Doing that gets obtuse and it would make more sense to have a function definition be formed in an order like preconditions : definition : postconditions, where concepts like access are preconditions, return value is post, but that formulation has it's own problems, in that arguments are preconditions. Since at the root of all of this we do want to keep the language beholden to mathematical syntax, parenthetical function definitions are pretty much a must. Another way to do this is something like:
  46.  
  47. public Main : array<string> Args, foo, bar, etc : null, where you use colons to seperate chunks of function definitions into a chain, but then their order becomes significant, cumbersome, and confusing, even if you save some glyphic overhead. ##
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement