rum icon indicating copy to clipboard operation
rum copied to clipboard

proposed keywords and operators for first beta

Open crgimenes opened this issue 7 years ago • 12 comments

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

crgimenes avatar Nov 29 '17 18:11 crgimenes

A ** operator for exponentiation would be nice.

brunoczim avatar Nov 29 '17 19:11 brunoczim

I think you could use the switch as pattern matching.

brunoczim avatar Nov 29 '17 19:11 brunoczim

switch: The word match makes more sense in functional language

avelino avatar Nov 29 '17 20:11 avelino

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

Logical and: (and true true)
Logical or: (or true true)
Logical not: (not true)

marioidival avatar Dec 10 '17 01:12 marioidival

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

crgimenes avatar Dec 10 '17 11:12 crgimenes

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

(! true)
(&& true false)
(|| false true)
(&& (! true) true)

marioidival avatar Dec 10 '17 12:12 marioidival

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

crgimenes avatar Dec 10 '17 12:12 crgimenes

Generally functional language use logical operators: and Example:

  • lisp
  • haskell
  • cloujure

I like a Scala approach that uses as we did

avelino avatar Dec 11 '17 00:12 avelino

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 avatar Dec 11 '17 00:12 avelino

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")

avelino avatar Dec 11 '17 13:12 avelino

include like this?

marioidival avatar Dec 11 '17 13:12 marioidival

yeah @marioidival

avelino avatar Dec 11 '17 13:12 avelino