mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-23 14:55:48 +03:00
e3a8cab943
This allows you to pass a thread directly into khan, instead of passing a filename. This has several implications: - The friction for using threads from an app is significantly lower. Consider: =/ shed =/ m (strand ,vase) ;< ~ bind:m (poke:strandio [our %hood] %helm-hi !>('hi')) ;< ~ bind:m (poke:strandio [our %hood] %helm-hi !>('there')) (pure:m !>('product')) [%pass /wire %arvo %k %lard %base shed] - These threads close over their subject, so you don't need to parse arguments out from a vase -- you can just refer to them. The produced value must still be a vase. ++ hi-ship |= [=ship msg1=@t msg2=@t] =/ shed =/ m (strand ,vase) ;< ~ bind:m (poke:strandio [ship %hood] %helm-hi !>(msg1)) ;< ~ bind:m (poke:strandio [ship %hood] %helm-hi !>(msg2)) (pure:m !>('product')) [%pass /wire %arvo %k %lard %base shed] - Inline threads can be added to the dojo, though this PR does not add any sugar for this. =strandio -build-file %/lib/strandio/hoon =sh |= message=@t =/ m (strand:rand ,vase) ;< ~ bind:m (poke:strandio [our %hood] %helm-hi !>('hi')) ;< ~ bind:m (poke:strandio [our %hood] %helm-hi !>(message)) (pure:m !>('product')) |pass [%k %lard %base (sh 'the message')] Implementation notes: - Review the commits separately: the first is small and implements the real feature. The second moves the strand types into lull so khan can refer to them. - In lull, I wanted to put +rand inside +khan, but this fails to that issue that puts the compiler in a loop. +rand depends on +gall, which depends on +sign-arvo, which depends on +khan. If +rand is in +khan, this spins the compiler. The usual solution is to either move everything into the same battery (very ugly here) or break the recursion (which we do here).
2 lines
5 B
Plaintext
2 lines
5 B
Plaintext
rand
|