Draft:Odin (programming language): Difference between revisions

Content deleted Content added
Xplane80 (talk | contribs)
Remove indentation style examples and add citation for optional semicolons; improve explicit procedure loading example
Xplane80 (talk | contribs)
m Improve grammar of swizzle section
Line 49:
 
== Design ==
Odin is designed as being an alternative for the [[C_(programming_language)|C programming language]] on "high performance, modern systems"<ref>https://odin-lang.org/</ref>, with features like compile-time [[parametric polymorphism]], [[array programming]], and [[Type_introspection|runtime reflection]].
 
=== Syntax ===
Line 91:
e := 1 + (c - d) / 2
fmt.printf("%.1f\n", e) // [0.5, 3.0, 6.5]
</syntaxhighlight>
</syntaxhighlight>Using <code>swizzle(array, indices..)</code> function, the elements of the array can be reordered in an arbitrary way. The indices specify the which element of the original array that is placed at a given spot in the new array. <code>swizzle(a, 3, 2, 1)</code> will reorder elements of 3 dimensional array to be in backwards order. For arrays up to dimension 4, there is a shorter notation for swizzling, using combination of letter ''x'', ''y'', ''z'', ''w'' in any order, akin to GLSL swizzling <code>a.zyx</code> <ref>https://www.khronos.org/opengl/wiki/Data_Type_(GLSL)#Swizzling</ref>.
 
</syntaxhighlight>UsingThe built-in procedure <code>swizzle(array, indices..)</code> function,allows the elements of the array can be reordered in an arbitrary way. The indices specify the which element of the original array that is placedto atbe a given spotplaced in thea new array. <code>swizzle(a, 32, 21, 10)</code> will reorder elements of 3an dimensionalarray arraywith length 3 to be in backwards order. For arrays up to dimension 4, there is a shorter notation for swizzling, using combination of letter ''x'', ''y'', ''z'', ''w'' in any order, akin to GLSL swizzling (e.g. <code>a.zyx</code> )<ref>https://www.khronos.org/opengl/wiki/Data_Type_(GLSL)#Swizzling</ref>.
 
<syntaxhighlight lang="go">
Line 115 ⟶ 117:
A <code>matrix</code> is a [[Matrix_(mathematics)|mathematical type]] built into Odin. It is a regular array of numbers, arranged in rows and columns. Odin's matrix support allows for ''matrix-array and matrix-matrix operations'' making it a [[Basic_Linear_Algebra_Subprograms#Level_3|Level 3 Basic Linear Algebra Subprogram]]ing language.
 
The following represents a :
<syntaxhighlight>
a: matrix[2, 3]f32 // matrix that has 2 rows and 3 columns with an element type of f32