Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(+2)

As noted in the previous post Ahm linked, Lil has uniform operator precedence; expressions are evaluated right-to-left unless parentheses are used.

The expression

x=1&y=1&z=1

In your first example is only working by coincidence; It is not equivalent to

(x=1)&(y=1)&(z=1)

But rather

x=(1&(y=(1&(z=1))))
(3 edits)

I did check out that link, but I honestly didn’t fully comprehend it. The explanation you provided has given me a lot more clarity. Thank you!

I had a sort of aha moment when I was customizing the datePicker and changed the text output to include the year beside the month at the top.

canv.text[""fuse month_names[p.month-1]," - ",p.year (0,5)+canv.size*.5,0 "top_center"]

I’m not a strong programmer, but I feel like that line’s syntax could only work evaluating right to left. Am I understanding that correctly? (More so about nesting the fuse command in there, I feel.)

Also, is the fuse command the only way to concatenate strings?


Edit: I guess I didn’t need the fuse part. I just edited it to:

canv.text[month_names[p.month-1]," - ",p.year (0,5)+canv.size*.5,0 "top_center"]

Nevermind, I have a lot more learning to do.

(+1)

The two ways of concatenating strings in Lil are fuse, which takes a simple string to intercalate between the elements of a list:

 " : " fuse "Alpha","Beta"             # -> "Alpha : Beta"

And format, which offers a richer printf-like string formatting language:

 "%s : %s" format "Alpha","Beta"       # -> "Alpha : Beta"  

The format primitive is useful in many situations, including gluing a fixed prefix and/or suffix onto strings:

"Prefix %s Suffix" format "MyString"   # -> "Prefix MyString Suffix"

In situations where a function, operator, or interface attribute expects a string, you can often get away with simply providing a list of strings (perhaps joined together into a list with the comma (,) operator) which will be implicitly fused together. Per The Lil Reference Manual for type coercions:

When a string is required, numbers are formatted, and lists are recursively converted to strings and joined. Otherwise, the empty string is used.

This is why you're able to elide the fuse in your example; "field.text" always treats a written value as a string

(+1)

That makes perfect sense. Thank you for your patience.