SeedV / SeedLang

An embeddable and visualizable scripting engine for .Net and Unity.
https://seedv.github.io/SeedLang/
Apache License 2.0
9 stars 1 forks source link

Support basic type conversion builtin functions #228

Open wixette opened 2 years ago

wixette commented 2 years ago

Without the following basic type conversion functions

bool()
str()
int()

It's hard to complete many simple tasks. For example, since SeedPython hasn't supported

f'Template string: {variable}'

yet, it's hard to mix strings and numbers in a single output line with the print() function like:

print(f'value = {value}')

Given there is no f'' template string, the following statement can be an alternative way for those cases:

print('value' + str(value))

Supporting basic type conversion functions will enable many possibilities.

BTW, repr() should be another story, which we can consider later, I think.

wixette commented 2 years ago

And, given we have already provided the print() function, we need to consider Python template strings seriously sooner or later:

'Hello, %s' % name

'Hey %s, there is a 0x%x error!' % (name, errno)

'Hey %(name)s, there is a 0x%(errno)x error!' % { "name": name, "errno": errno }

'Hello, {}'.format(name)

'Hey {name}, there is a 0x{errno:x} error!'.format(name=name, errno=errno)

f'Hello, {name}!'

f"Hey {name}, there's a {errno:#x} error!"

This will be a big task. Above all these forms, maybe we can only support one or two of them.