teo_zero
2 days ago
I'd like to come up with some constructive comments, but I find everything so inconsistent and alien to me...
For example, variable declarations use the pattern <colon> <type>, as in
var a: Int32
But literals follow the opposite syntax, as in a = Int32: 42
The return type of a function is introduced by : in func definitions, but by -> in imported func declarations: func foo(a:Int):Int
import func bar(a:Int) -> (Int)
Other construct that I find far from my habits: var w, h, d = 640, 480, 2
instead of the more obvious (for me): var w=640, h=480, d=2
Arguments are passed by ref, not by val. Good luck with recursion!marckerbiquet
2 days ago
Author here. The language has still many inconsistencies but not these ones.
Import functions is done the same way:
func foo(a: Int): Int
import func foo(Int): Int
May be the doc is outdated.The multiple declaration is consistent with assignment:
var w, h = 640, 480
w, h = 640, 680
w, h = getBoundingBox(obj)
The syntax var a = Int: 32
is unusual compared to many other languages because it just use a simple syntax: var id = expr
The type is prefixed only to resolve literals: var a = Int32: 42
var b = Uint8: 42
It can be useful in generic functions: println("The answer is \a", Float32: 42)
But to create uninitialized variables I had to keep the syntax: var id: Typeteo_zero
18 hours ago
> Import functions is done the same way [...] > May be the doc is outdated.
Same for function types? The docs still list the syntax with "->":
& (Type) -> (RetType)marckerbiquet
16 hours ago
This one is up to date and it's definitely inconsistent, but I could not use ':' in place of '->' without creating an ambiguous grammar. Same for parenthesis in the return type since you can have a comma separated list:
& (Type) -> (RetType1, RetType2)RX14
a day ago
Have you considered the syntax crystal uses i.e. 42_i32 and 42_u8?
marckerbiquet
16 hours ago
It is not possible since you can create new integer types by sub-classing the primitive ones:
class UserId: Int64
...
end
var user = UserId: 42
I also plan to replace predefined Int64, Int32, ... by generic types Int(64), Int(32), ... LLVM allows any integer size and Copper allows this kind of generic types.yxhuvud
2 days ago
The parallel assignment just work mostly like it does in ruby so that doesn't look weird to me (except the need for 'var' in the first place).
Agreed on the rest, though I don't understand what the problem would be with recursion. Is it using reference passing also for primitives like integers?
teo_zero
2 days ago
> Is it using reference passing also for primitives like integers?
That's what I assumed, but honestly I might have misunderstood the docs. This passage is not very clear:
> Copper manipulates only references to objects. Simple data types such as integers must be seen as references to stateless objects (i.e. objects that have no state in memory).
yxhuvud
2 days ago
Sounds like they store the integer in the reference itself in that case. Which also is how Ruby does things (though Ruby has to decide what is what at runtime and thus steal a couple of bits off every integer).
Muhammad523
2 days ago
Python does that too
antihero
2 days ago
Is this not destructuring a tuple?
metadat
2 days ago
Agreed.. and what is going on with the `!` syntax? The docs are not exactly clear on the purpose in all cases.
teo_zero
2 days ago
I think it's the opposite of & in C++, that is T! is an object, while T is a reference to an object.