Eclalang / Ecla

Ecla is a programming language that is designed to be easy to learn and use. It is a general purpose language that can be used for many different things.
https://ecla.dev
MIT License
79 stars 0 forks source link

Return no nothing "%s" #118

Closed GuillaumeDupuy closed 11 months ago

GuillaumeDupuy commented 11 months ago

The code :

import "console";

console.printInColor("red","Test For range\n");

var hello string = "Hello World";

for (index,elem range hello) {
    console.printf("index = %d, elem = %s\n", index, elem);
}

The result :

Test For range
index = 0, elem = %!s(int32=72)
index = 1, elem = %!s(int32=101)
index = 2, elem = %!s(int32=108)
index = 3, elem = %!s(int32=108)
index = 4, elem = %!s(int32=111)
index = 5, elem = %!s(int32=32)
index = 6, elem = %!s(int32=87)
index = 7, elem = %!s(int32=111)
index = 8, elem = %!s(int32=114)
index = 9, elem = %!s(int32=108)
index = 10, elem = %!s(int32=100)
mkarten commented 11 months ago

i have ran the same test in golang :

import "fmt"

fmt.Println("Test For range")

hello := "Hello World"

for i, v := range hello {
  fmt.Printf("index = %d, elem = %s\n", i, v)
}

and it outputs :

Test For range
index = 0, elem = %!s(int32=72)  
index = 1, elem = %!s(int32=101) 
index = 2, elem = %!s(int32=108) 
index = 3, elem = %!s(int32=108) 
index = 4, elem = %!s(int32=111) 
index = 5, elem = %!s(int32=32)  
index = 6, elem = %!s(int32=87)  
index = 7, elem = %!s(int32=111) 
index = 8, elem = %!s(int32=114) 
index = 9, elem = %!s(int32=108) 
index = 10, elem = %!s(int32=100)

so the issue is not relevant to ecla but instead the go implementation of Printf in the fmt package that is used in the underlaying ecla standard library