
Cor 0.3.0 released - yosbelms
http://yosbelms.github.io/cor
======
dchest
_Cor does not has a keyword to declare variables, instead, Cor declares it for
you the first time it is used. If a variable with equal name is declared in
outer scope the compiler will assume you are using the declared outside.
Unless you write the variable as a simple statement. This technique is called
variable announcing._

Sadly, it's the same mistake that CoffeeScript made: you cannot just introduce
a variable, to be completely sure you didn't break anything, you'll have to
search for all uses of it in outer scope above and inner scopes below.

[https://donatstudios.com/CoffeeScript-
Madness](https://donatstudios.com/CoffeeScript-Madness)

~~~
yosbelms
"Variable announcing" solves that issue, please see the example in the
following link:

[http://yosbelms.github.io/cor/docs/playground/index.html#lin...](http://yosbelms.github.io/cor/docs/playground/index.html#link:---%0Aexample%20of%20announcing%20variable%0A---%0A%0AsomeVar%20%3D%200%0A%0A%0A%2F%2F%20see%20how%20to%20use%20outer%0A%0Afunc%20usingOuter\(\)%20%7B%0A%20%20%20%20someVar%20%3D%200%0A%7D%0A%0A%0A%2F%2F%20see%20the%20compiled%20code%20in%20the%20right%2C%0A%2F%2F%20notice%20the%20declaration%20inside%20the%20scope%0A%0Afunc%20avoidingOuter\(\)%20%7B%0A%20%20%20%20someVar%0A%20%20%20%20someVar%20%3D%200%0A%7D)

~~~
dchest
I understand that you can announce variable, but to be save, you'll have to
announce it in every scope you want to declare it, so why not just use "var"
or ":=" to declare and assign?

~~~
yosbelms
Looking for simplicity. One of the goals of Cor is to have few keywords, to
make it easy to learn, to get involved, and to work with. I had three possible
solutions to solve the variable scoping problem.

1- `var` keyword. Like javascript. It assumes all variables are global if not
declared with `var`. 2- `global` keyword. Like PHP. It assumes all variables
are local unlike that is annotated with `global`. 3- Ruby-like, Coffeescript-
like.

A mixing of options number 1 and 3 was chosen.

I will open an issue regarding this subject, considering your proposal for
future versions.

~~~
dchest
Thank you. Actually, what I think the best way is to make it an error to use
undeclared variable, unlike in JavaScript. If it's a global, is should be
declared in global scope. I really like this way of declaring variables, so
please consider it:

    
    
      someVar := 123 //declared and assigned
      someVar = 456 // reassigned
      anotherVar = 777 // error: undeclared variable

------
stupidcar
Not sure I really see the point of this. The syntax seems to offer little
beyond what's possible already in ES6, and is missing several features, such
as generators, destructuring, rest and spread operators and template strings
that are very useful in modern JS development.

~~~
yosbelms
Most of the design of ES6 is like this due to backward compatibility. I'm very
sure if the comunity behind ES6 specs designs a language for the web
regardless backward compatibility, ES would be very different to what it
actually is. These features you are mentioning are awesome, for sure. But ES6
is bloated for sake of having features plus backward compatibility. Cor is
different, it is simple but modern, it is going in the opposite direction.

------
yosbelms
Release notes:
[http://ost.io/@yosbelms/cor/topics/5](http://ost.io/@yosbelms/cor/topics/5)

------
gravypod
This is the first transcompiled JS language I've seen that I have wanted to
use. It's as strait forward as JS, but adds a lot of features I wished the
language had.

