Category:Arturo: Difference between revisions
Content added Content deleted
Drkameleon (talk | contribs) No edit summary |
Drkameleon (talk | contribs) No edit summary |
||
Line 8: | Line 8: | ||
|tags=arturo |
|tags=arturo |
||
|gc=yes}} |
|gc=yes}} |
||
'''Arturo''' is a |
'''Arturo''' Arturo is a modern programming language, vaguely inspired by various other ones - including but not limited to [[Rebol]], [[Forth]], [[Ruby]], [[Haskell]], [[D]], [[SmallTalk]], [[Tcl]] and [[Lisp]]. |
||
===Principles=== |
===Principles=== |
||
The language has been designed following some very simple and straightforward principles: |
|||
* Code is just a list of words and symbols |
|||
====Everything is a simple statement==== |
|||
* Words and symbols within a block are interpreted - when needed - according to the context |
|||
* No reserved words or keywords - look for them as hard as you can; there are absolutely none |
|||
<code> |
|||
There are no "special" language constructs (*even `if` is nothing but a simple statement*). Everything you see is a statement in the form <code>ID <expression> <expression> <expression> ...</code>. An assignment is nothing but a labeled statement. <code>LABEL: <statement></code> |
|||
print "Hello world!" |
|||
<br> |
|||
====Code is data - and data is code==== |
|||
loop 1..10 'x [ |
|||
Arturo can be used both as a data-interchange format and a programming language. Basically all data structures are valid code and all code can be represented as a data structure. Think of it as [[SDL]]/[[Json]]/[[YAML]]/[[XML]] combined with the power of [[Lisp]] - but without the... sea of opening and closing parentheses. |
|||
if? even? x -> print [x "is even"] |
|||
<br> |
|||
else -> print [x "is odd"] |
|||
====Each statement returns a value==== |
|||
] |
|||
</code> |
|||
⚫ | |||
Whether what you would consider a "function" or any other statement, it will return a value. If it's a block of code (see: ''function''), the last statement's result will be return - unless specified otherwise. |
|||
The main compiler is implemented in [[Nim]]/[[C]] as a Bytecode interpreter / Stack-based VM and should run in most architectures. |
|||
<br> |
|||
====Functions are first-class citizens==== |
|||
The main goals are: performance, energy-efficiency and portability. (With that exact order) |
|||
Functions - or blocks of statements enclosed in <code>{}</code> - can be anything. Assign them to a symbol/variable, pass them around as arguments to function calls, include them as a dictionary key value, or return them from a function. And of course they can be either named or anonymous/lambda. |
|||
<br> |
|||
====Uniform syntax==== |
|||
There are 3 types of statements. |
|||
* Simple statements, that work as a function call in the form of <code>ID <expressions></code> |
|||
* Expressions (Yes, <code>1+2</code> is also a valid statement) |
|||
* Labeled statements (see: assignments) like <code>a: 2</code> |
|||
Pro tip: Do you want to use the result of a statement as part of an expression? Just enclose the function call in square brackets <code>[...]</code> E.g.: <code>print [reverse #(1 2 3)]</code> |
|||
⚫ | |||
The main Arturo interpreter is written in the [[Nim]] language. |
|||
===License=== |
===License=== |
||
Line 48: | Line 38: | ||
[[Reports:Tasks_not_implemented_in_Arturo]] |
[[Reports:Tasks_not_implemented_in_Arturo]] |
||
⚫ | |||
{{language programming paradigm|Imperative}} |
{{language programming paradigm|Imperative}} |
||
⚫ | |||
{{language programming paradigm|Functional}} |
{{language programming paradigm|Functional}} |
||
{{language programming paradigm|Reflective}} |
{{language programming paradigm|Reflective}} |