rumlang / rum

Functional language, easily extensible and possible (Lua features with LISP dialect and functional) to be embarked on software Go!
https://www.rumlang.org/
MIT License
157 stars 13 forks source link

proposed keywords and operators for first beta #60

Open crgimenes opened 7 years ago

crgimenes commented 7 years ago

These are some ideas of, keywords and operators for the first beta of the language. Some of keywords we have not even defined the syntax. Please comment, suggests modifications, and if you're feeling inspired, implement :D

Operators: https://github.com/rumlang/rum/wiki/Operators Keyworkds: https://github.com/rumlang/rum/wiki/Keywords

All discussion should be made in this issue and updated on the wiki page

brunoczim commented 7 years ago

A ** operator for exponentiation would be nice.

brunoczim commented 7 years ago

I think you could use the switch as pattern matching.

avelino commented 7 years ago

switch: The word match makes more sense in functional language

marioidival commented 6 years ago

IMHO, it's better than || && !

Logical and: (and true true)
Logical or: (or true true)
Logical not: (not true)
crgimenes commented 6 years ago

I prefer operators ||,! and &&... it has more "operator like" for me :D but maybe I'm just used to it.

marioidival commented 6 years ago

So ugly 😬. these operators is cool to languages with no have boolean value or system language, haha

(! true)
(&& true false)
(|| false true)
(&& (! true) true)
crgimenes commented 6 years ago

The beauty is in the eyes of the beholder... (a D&D Beholder)

avelino commented 6 years ago

Generally functional language use logical operators: and Example:

I like a Scala approach that uses as we did

avelino commented 6 years ago

Assignment Operators

Operator Description Example
+= Add AND assignment operator, It adds right operand to the left operand and assign the result to left operand (+= C A) A is equivalent to C = C + A
-= Subtract AND assignment operator, It subtracts right operand from the left operand and assign the result to left operand (-= C A) is equivalent to C = C - A
*= Multiply AND assignment operator, It multiplies right operand with the left operand and assign the result to left operand (*= C A) is equivalent to C = C * A
/= Divide AND assignment operator, It divides left operand with the right operand and assign the result to left operand (/= C A) is equivalent to C = C / A
%= Modulus AND assignment operator, It takes modulus using two operands and assign the result to left operand (%= C A) is equivalent to C = C % A
<<= Left shift AND assignment operator (<<= C 2) is same as C = C << 2
>>= Right shift AND assignment operator (>>= C 2) is same as C = C >> 2
&= Bitwise AND assignment operator (&= C 2) is same as C = C & 2
^= bitwise exclusive OR and assignment operator (^= C 2) is same as C = C ^ 2
\|= bitwise inclusive OR and assignment operator (\|= C 2) is same as C = C | 2
avelino commented 6 years ago

include: load file .rum this file point

test1.rum

(print "print test1")

main.rum

(package "main"
  (print "start")
  (include "test1.rum")
  (print "end"))

output:

start
print test1
end

include differs from import, import as object where it is possible to use as Object: ex (import test2) (print test2.Function)

Multi include (include "test1.rum" "test2.rum")

marioidival commented 6 years ago

include like this?

avelino commented 6 years ago

yeah @marioidival