Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

How do you use Lilt?

A topic by Internet Janitor created Apr 15, 2023 Views: 461 Replies: 9
Viewing posts 1 to 4
Developer(+1)

Since v1.9, I have provided APE builds of Lilt, the standalone command-line Lil interpreter, as a companion application to Decker.

It seems to get a moderate number of downloads for each release, and I'm curious to hear how it's being used by you folks. Are you using it to learn Lil? To automate the creation of decks? Did you download it by accident? Are there features you find particularly useful, or features you wish it had?

Your thoughts and experiences could be very useful for shaping my future work on this tool.

(+1)

i downloaded it to check it out, but haven't gotten around to it yet. but i think it would be good to play around with.

(+1)

I have been experimenting with using lilt in those places where I would normally write little bash or lua scripts to preform repeatable utility sorta tasks. 

Bash is convenient and portable, and bolted to my bones, but there are times when it gets unwieldy...I'm also sufficiently poisoned to function programing, so, find myself reaching for functionality that isn't there in bash (namely map, filter, etc). lil, through lilt is oh oh oh so close to being a suitable replacement for the little things I reach to do, but has edges that are just hairy enough I haven't made it a day-to-day choice, yet. 

Developer (1 edit)

If you can recall any specific hairy edges, please share! Without user feedback, the only use-cases I've had to guide improvements are the things I've done myself, like using Lilt to re-slice images for gamedev projects, writing test fixtures, doing bulk image-import, and the occasional code-golf puzzle.

(1 edit) (+1)

Here is a sample file to demonstrate 2 issues I ran into last night.

The docs note that you don't need to seed random, but, every time I run random (at least on a given day, I haven't tried across days) I get the same result 

The other issue is with a for/else blocks not working as expected when testing passed args[] against known values, e.g. args[2] ~ "-l"

[edited to add that I'm using a version of lilt built form source the same day that Decker 1.7 was announced here on itch]

Developer(+1)

Thank you for explaining your issues in more detail!

In Decker, the random seed is pre-initialized to a random value. In Lilt, it is consistently seeded out of the box. From the Lilt Documentation:

Choose y random elements from x. In Lilt, sys.seed is always pre-initialized to a constant.

The idea behind this is that Lilt behaves deterministically until you explicitly want randomness, which simplifies testing. This is also how random numbers have always worked in the K interpreter. I admit that this might be a footgun for the unwary, so I'll give changing the default some thought. For now, you can initialize the RNG with something like 

sys.seed:sys.ms

I gave your argument-parsing example a spin, and it works as expected for me. The "elseif" construct was introduced in Decker/Lilt version 1.16. In older versions of Lilt, "elseif" was not a keyword, so it would have just been a reference to an undefined variable with a value of 0, and then the predicate would similarly have been evaluated and then discarded. This explains why you're seeing the code behave as if the 'elseif args[2] ~ "-m"' line doesn't exist.

If you're using 1.7, please rebuild from source or download a fresh executable- there have been many improvements, bugfixes and additions in the last 9 releases. :)

(+1)

Thank you! This was super helpful. I'd totally misunderstood how the random seed was expected to work -- what you've described here makes a lot of sense to me, now, and with that things are working a-okay. 

Also, I'm feeling foolish to admit that I thought I was running 1.17, but was actually a few versions behind on lilt 馃う that was totally my bad! 

Perhaps fewer hairy edges than I initially thought! In the end, the only hairy edge was me. 

(+1)

Following up with an example of something I've used lilt for! It isn't much, but I'm hoping it becomes a part of a larger cli game I've got brewing. 

I've re-implemented a bit of code that I've written a few times in a few languages that creates nonsense, but mostly pronounceable words. 

My goal here was to implement it in what felt like the most idiomatic flavor of lil I could. I've provided a links to previous iterations of this code as a way to compare and contrast the capabilities of lilt. While this is a pretty minimal example, I found it insightful to write. 

Developer (1 edit) (+1)

That's a fun idea- thank you for sharing!

A few suggestions:

  • Instead of using "," to join together long lists of string literals, you could use "split" on a single string. This is more concise, but also a bit more efficient at runtime, since Lil does not (currently) pre-evaluate constant expressions. The following lines are equivalent:
("A","B","CD","EFG","H","I")
"|" split "A|B|CD|EFG|H|I"
  • If the random[] function is given a single list argument, it will select a single value from that list, whereas specifying a "1" as the second argument will produce a list of length one. The former case appears to be closer to what you want. The following lines are equivalent:
sum random[(1,2,2,3,4) 1]
first random[(1,2,2,3,4) 1]
random[(1,2,2,3,4)]
random[1,2,2,3,4]
  • We don't strictly need to "fuse" in both syl[] and word[]; the string-cast of a list of strings is their concatenation, so a single fuse at the top level will collapse nested lists-of-lists-of-strings:
   (list "A","B"),(list "C","DEE","EFF") 
(("A","B"),("C","DEE","EFF"))
   "" fuse (list "A","B"),(list "C","DEE","EFF")
"ABCDEEEFF"
  • We can simplify slightly by referencing cons/vow in syl[] as globals, instead of threading them through word[]/syl[] as arguments. Once syl[] doesn't take any arguments, we can observe that the "@" operator is a shorthand for the loop in word[]. The following lines are equivalent:
each x in i syl[] end
syl @ i

All together, I think I might factor this program as follows:


(+1)

Thanks so much for this super detailed walkthrough! I just learned a heap! My first instinct was to use the @ operator, but I see now that I was going slight awry when I was trying to make the right value a single integer 馃う

This is absolutely gorgeous. To "get" lil more, I've been reading through a few things on apl and k. lil is proving to be a lovely "on-ramp" to array programming for my sufficiently poisoned brain that is stuck in a deeply functional rut. .