Skip to content

Thecarisma-syntax.md#2

Open
ladaposamuel wants to merge 1 commit intomasterfrom
Thecarisma
Open

Thecarisma-syntax.md#2
ladaposamuel wants to merge 1 commit intomasterfrom
Thecarisma

Conversation

@ladaposamuel
Copy link
Copy Markdown
Collaborator

No description provided.

@appcypher appcypher self-requested a review November 12, 2019 22:13
Comment on lines +38 to +42
- The `const` keyword is used for subject which value cannot change.
```cpp
const name = "John"
name = "Doe" // Invalid!
```
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't agree with using const for constants because it is verbose and would be tiresome to keep typing since it is going to be used a lot code. let as a constant is not a new syntax on the block. They have been popularised by Swift and Rust. We could also use val as popularised by Kotlin and Scala, but I think let is more expressive.

In modern languages, constants tend to be used quite a lot, because there is these notion of immutability by default, therefore these languages try to keep the keyword as short as possible. Usually as three letter words. val and letbeing the notable ones.

If you do a quick grep on any repo with code written in modern languages, you will notice constants are declared way more than variables.

```

```rust
const name = (condition ? "John" -> "Peter" )
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me, the -> operator looks a bit confusing considering the fact it uses the same operator as the return statement.

At first glance, one would expect that it follows the same style of after the -> operator, a return type follows immediately.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @tnkemdilim on this. We should disambiguate symbols and the tokens. If it already means something before. It shouldn't mean something else.

Maka Safety....

- A `for` loop iterates through an iterable and binds the value to a subject.

```py
for i in 1:11 {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this for 1 to 10 (exclusive of 11)?

A quick suggestion, how about having a syntax for the last number included e.g. :=?

I believe having an inclusive range syntax would improve the way people would write (instead of +1 every single time).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, how does on include a step size for the loop ? We can't afford to make including a step size arg to a for loop with : as cumbersome as it is currently in python 3 if you ask me.

Comment on lines +506 to +508
trait Callable {
call: (...Int) -> Int
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I so much agree with the idea of adopting traits.

Although, we'll have to take into consideration certain scenarios, and establish a means for resolution. E.g.

  • Multiple traits with at least 1 similar function definition,
  • Can traits inherit other traits?
  • etc.

- Declaring a generic function

```swift
impl Buffer:[T] where T < Integer {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's quite a lot going on here. Apparently, we are enforcing that the size of T is less than an Integer.

What operators are permitted in such scenarios?

I'll advise we give this a thoughtful and close look before proceeding.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This syntax carries a lot of implementation implications going forward. We really need to get much more grounded on what implementation will look like in time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants