Automatic initialization #24
Replies: 2 comments 2 replies
-
Hi, Actually compiler already has this feature but only for return variables of functions. So, why this feature isn't allowed for variables? From Jule Manual;
This in particular was not always part of the Jule design. The Jule has undergone great changes over time and has adopted this approach somewhere in the process. Knowing how which variable is initialized is considered part of safety. Actually bringing back auto initialization is in the plans. Because this is already an obsession for the compiler and not applicable everywhere. This is for variables only. For example, you are not required to initialize return variables and struct fields, they are automatically initialized by the compiler. This makes it meaningless to have such an obsession with variables. This design element used to make sense, but has no clear meaning in current Jule. Earlier development phase versions had stricter rules for the compiler about explicitly initializing structures and the like. These are no more. So this old design element of the compiler on variables will be removed. |
Beta Was this translation helpful? Give feedback.
-
Wow, you are fast! Thank you for the historical explanation, and I fully understand the logic behind the approach creating a safe programming language. That's why I'm on the fence of (in any programming language) liking type inference or not... but I tend to dislike it. Tha's why I like that Jule lets me define the type with: I will surely spend more time with Jule... |
Beta Was this translation helpful? Give feedback.
-
Hello,
I'm wondering if there are any plans to make automatic initialization at declaration possible.
Now Jule code looks like this:
let mut my_slice: []str = nil
let mut my_int: int = 0
let mut my_int: []int = [0]
Would be nice to be able to:
let mut my_slice: []str
let mut my_int: int
let mut my_int: []int
Without the need to manually initialize them.
The compiler could do it on its own if there is no
=
after the type definition.Thanks
Beta Was this translation helpful? Give feedback.
All reactions