lang: funcs: core: fmt: Add variant verb for printf

There's no reason we can't support a %v variant verb. Of course it makes
type unification more difficult, and certain uses of this will produce
unsolvable situations, but it's useful for debugging, and fun to have.
This commit is contained in:
James Shubin
2021-10-11 00:36:29 -04:00
parent 88516546fa
commit e9791ff92c
3 changed files with 44 additions and 9 deletions

10
examples/lang/printf0.mcl Normal file
View File

@@ -0,0 +1,10 @@
import "fmt"
test "printf-a" {
anotherstr => fmt.printf("the %s is: %d", "answer", 42),
}
$format = "a %s is: %f"
test "printf-b" {
anotherstr => fmt.printf($format, "cool number", 3.14159),
}

View File

@@ -1,10 +1,10 @@
import "fmt"
test "printf-a" {
anotherstr => fmt.printf("the %s is: %d", "answer", 42),
anotherstr => fmt.printf("the %v is: %v", "answer", 42),
}
$format = "a %s is: %f"
$format = "a %v is: %v"
test "printf-b" {
anotherstr => fmt.printf($format, "cool number", 3.14159),
}