#🪅-progaming
1 messages · Page 90 of 1
i did some reading and apparently some other languages need you specify a power
what like scientific notation?
Hex Floats (Using the GNU Compiler Collection (GCC))
pretty confusing to me
oh it's just for ambiguity of f in this case
Golang online books, articles, tools, etc.
yeah not sure if i need this
this is neat
also golang has imaginary numbers??????? as literals?????
i mean thats nothing new so does python
no
@valid jetty does your family not care that you never sleep
Honestly id want to have such energy for programming too
yeah energy like that for me usually comes in cycles
i donmt have that much energy
protokolle stream controller is around 500
but it has some fancy animations so it’s a container in another view
add like idk 200 to that
don’t be worried about how many lines it is but I would worry if it’s that many lines and is a horrible mess
just make sure everything is organized and makes sense
Use extensions if possible to help with code organization
why do u have a separate enum for punctuation
Punctuation(';') is superior
https://apps.apple.com/us/app/protokolle/id6746388316 @royal nymph @young flicker
hahaha they allow it
protokolle
[ PROTC
KOLLE ]
HUGE
why does your lexer parse
Twitch
Everything is built live on twitch
Twitch : https://bit.ly/3xhFO3E
Discord: discord.gg/ThePrimeagen
Spotify DevHour: https://open.spotify.com/show/4MLaDrQcQ5mi3rsnvWkwPt
Editor
All my videos are edited by Flip. Give him a follow! https://twitter.com/flipmediaprod
Join this channel to get access to perks:
https://www.youtube.c...
Good advice, I should keep that in mind from time to time
so i can do “>=“ and “>”. although i could do that in the parser too
does it?
it's probably fine tbqh
i just get alarm bells when i see complex number types handled by the lexer
Wouldn’t dealing with ‘0’, ‘x’, ‘ff’ be worse in the parser
it's up to whatever you find easiest to handle
What does 0xff have to do with complex
Also that
Things like python's 1j definitely go in lexer though
why does +2 consume the 2
i know it’s unary but it should be contextual whether it’s lexed as unary or binop
I'm handling unary vs binops in the parser
insane
you could do what i do 
have a condition to check the previous token and if it’s not a specific kind you parse the punct as unary otherwise binary
beware the context to parse as unary is pretty huge

enums.rs: Lines 235-255
pub const fn is_unary_context(self) -> bool {
matches!(
self,
Self::LeftParenthesis
| Self::LeftCurlyBrace
| Self::RightCurlyBrace
| Self::LeftBlockBrace
| Self::Comma
| Self::Colon
| Self::Not
| Self::Semicolon
| Self::Return
| Self::While
| Self::For
| Self::If
| Self::Equal
| Self::Question
| Self::In
) || self.is_declarative()
|| self.is_arithmetic()
}
What point is there even in parsing - as part of the numeric literal?
rosie i wanna work on icy but i havent finished wordle yet and im completely lost
that’s the thing, -39 and +39 are themselves literals which become -1 * 39 and 1 * 39 respectively
i just save those as GreaterEqual
and GreaterDot ig? tho i dont have that
which sounds bad on paper but qbe does constant folding so it is actually ok
how else would you do it if - isnt a function
- isn't a function, it's a token
hint - it’s related to drama and arts
1 green 1 yellow 4/6 ONE DUPLICATE LETTER
it is a function if you want it to be
eagely fubction
why does discord have wordle now
it’s actually a benefit
i can’t run it on my phone because my ios is too old
but i can run the discord version
wait why does this work
nvm makes sense
i didnt know i could use no arg functions (variables) standalone
ooo function aliases come for free!!!!
i might put print = println in the prelude so i stop forgetting to write ln
the wonders of an interpreter
i can do that but it didn’t come for free
NO BUT HOW WAS IT THAT EASY
well i had to implement variables which isnt free
but this wasnt the intention
time for lists
@valid jetty is there any reason to use x:xs over arraylists
wdym
yes i love when it makes my entire function unreadable with yellow lines just because its too long
this is why you don’t enable clippy in zed
all the functional languages have linked lists with x:xs
yeah
this isnt zed
oh
but i think imma keep it enabled
this is actually awesome it configures r-a for you https://github.com/mrcjkb/rustaceanvim
if you’re suggesting to make arrays be sugar for linear contiguous allocation instead of linked lists, that is an optimization and not technically correct functionally
something like haskell would do that as an optimization step but purely functionally speaking arraylists do not exist
i wanna make a builtin function list that makes you a list (probably by taking a generator function as a param or something) and just return a Value::List { vec: Vec<Value> }
well i need arraylists for aoc
you should implement pairs and pair destructuring
then write functions that operate on the pairs like arraylists
how would i do that when its a linked list
the internal representation of the structure shouldn’t be relevant at the call site
all you’re doing is map arr (\x -> x * 2)
you don’t need to know whether arr is an arraylist or linkedlist
maybe i just make iterators first?
yes i saw

i love implementing concepts i learnt from rust in non-rust
(phantom generics, Boxing, type erasure)
except my stuff literally just doesnt work if i dont do this
my parser was completely broken until i rewrote it almost from scratch
fix
im gonna fix clippy issues first
is there some crate or a smart way to have some sort of a resources folder in rust?
just need to have a 100kb json file to be used in the app
and i'd rather it to be loaded dynamically than to be like included into the PE
so its size doesn't get too big
though 100kb isn't that much
i guess
icypeas is 4.9MB
and its a really small program with no deps
100kb shouldnt be an issue
im just worried cuz the app is supposed to be running in background
so i want to make it as small as possible
well how big is it rn
running in the background on a microcontroller?
idk i havent finished it yet 
^
if not then 100kb is really gonna be irrelevant
well does it compile rn
i mean its not ready at all
well just check how big it is rn
do i just cargo build --release
ye
oh its 679K in release mode
yea so 100kb is irrelevant
yeah
[dependencies]
anyhow = "1.0.98"
reqwest = { version = "0.12.15", features = ["blocking", "json"] }
serde = { version = "1.0.219", features = ["derive"] }
serde_json = "1.0.140"
there u go
i can prob replace serde with just serde_derive ig?
theres ur 2.8mb
pretty sure serde { features = derive } is the same as serde_derive
-Os when
im not running it on a microcontroller
it can be a gb for all i care
i wonder how big elle is
is it possible to like uhh free memory from that big ass json file once i convert it into structs getting rid of extra stuff i dont need? cuz like it should take less memory if i just store it as structs rather than pure bytes obviously but will i be able to like get rid of the plain bytes in memory? idfk how to epxlain it better
ellec is only 5.6mb lmaooo
not that big
then again i ```toml
[profile.release]
opt-level = 3
yea ofc just call drop manually surely
as long as you copied the bytes over into your structs instead of storing a reference to them ofc :3
i see
won't rust do it automatically
i mean free the included bytes
once out of scope
or something
well yeah
but i assumed you do it in the main function
like you just ```rs
fn main() {
let bytes = read_thibg_colon_3();
let (x, y, z) = parse_bytes(bytes);
std::mem::drop(bytes);
do_stuff(x);
// ...
}
xxd -i
something something bindgen
more effort than its worth imo
tbh wouldn't be that hard to make for rust instead of c
im sure theres some macro in the stdlib to embed some file at compile time into the code
isnt it just include!
also you could prob easily re-rcreate what xxd does for rust, or convert it into rust and parse it with libclang or smth
cant you do this
const a: &[u8] = include_bytes!("path/to/image.png");
``` idk
yeag
i wonder if i should do include_str or include_bytes
cuz like its json
it should be a valid utf-8 string anyways
include_str
neat
you could prob generate a structred rust file with your resources
tbh i think i'll stick with just dynamically loading the file with fs
include_str/bytes seem a bit confusing to me idk
They aren't confusing at all though
im just dumb then 
you literally just put
const my_json_stuff: &'static str = include_str!("path/to/your/file.json");
fn main() {
// wow use..
}
as far as im aware
though keep in mind none of that will be dropped
because its in bss
that is what makes me not really wanna use it
It's memory-mapped, i.e. essentially free
yeah this embeds it in the binary so if this is what you want then go for it
also consts use screaming snake case
sorry...
(i'm not actually sorry)
dont worry rust will shout at you when you try to compile
am i coding in zig 
no its good but if you want to, you could just remove the decl
what am i doing 
i don't think this is how you want to use that
why are you mem dropping a static str
youre serializing it and then dropping it?
i have no idea what i’m doing. i just want to like get rid of it from memory since i already have it structured via PiaResponse
it sounds like you want a lazycell
A value which is initialized on the first access.
this, actually
A synchronization primitive which can nominally be written to only once.
i got confused by the names lol they changed it
anyway this lets you store the data in a static after you parse it
and as such the string will be dropped automatically
once the lock is done evaluating
so uhh sorry how do i use it? basically i think i want something like that:
include_str!("my_json_file.json");
then deserialize it with serde_json
store the retrieved struct in a static variable or something
free the included str from the beginning
you don't want to use include_str in this case i don't think
a regular file read will work fine
yeah that's what i thought too
include_str embeds the bytes in the binary afaik so there's nothing to free
it's like. part of the executable
is there a simple way to make my json file always be next to the compiled PE when building? or only by creating build.rs?
Shell script
Cargo does not give a damn about what happens to your exe after it's built
or like make / just?
Yeah or something simpler like a shell script
im on windows 
you're a big boy you can write a powershell script
It is for setting up the environment so that the package can be built
It has nothing to do with what happens after
yes but you can also use it for not that
Yeah and you can use a toaster for frying eggs
pwsh is kinda scary. also im planning to make this app multi-platform so i guess i'll just use make or just
i mean
is it actually a common practice to use makefiles with a cargo project?
god no
i don't see why you can't use the build.rs to throw the json file into the cargo output dir
idk which of u to listen to 
hello i'm a senior software engineer nice to meet you
afaik you can get the cargo target dir in the build.rs
aight!
ngl that would be a great opportunity for me to try just 
also what should i use to create executables for rust apps
for windows and other OS’s
cargo cross
@spark tiger alright
so
you can use env!("OUT_DIR")
never mind i lied
you need to use std::env::var
okay there we go
OUT_DIR is where artifacts / binaries get placed
i’m so dumb i meant to say installers
😭😭😭
i see thanks!
i mean... it's a flat executible right?
just a small wireguard wrapper
you can just use a msi or write a shell script
well but it needs to have a json file next to it 
you want something like cargo-dist
see above
honestly i'm really confused
why are you so concerned about the json file being in the binary
why do you want a json file next to the binary, or inlined in the binary, what are you making
are you targeting a 256kb machine or something
the json contains a big list of one vpn provider’s servers
json file MUST be there
seemingly does not want json file to be embedded in binary
wants json file to be there alongside binary
iunno i just overthink and overcomplicate things when im coding in rust for no particular reason
lol yeah
trust me
you can embed it
it'll be fine
you're not gonna get beaten up
if you want the json file to ever change, that's a different story
yeah but i was just worried that i will basically have two instances of the same data in the memory: one is plain json string and another is my own rust struct with same data
The string isn't even in ram
but it’s in PE. doesn’t a process always contain everything from the PE?
Yes, mapped in virtual memory
if you're worried about a single json file worth of data, well, i have BAD news for you regarding essentially all of the electron apps you have installed on your system right now 
eli5
i have 1tb of games on steam installed and i only play like five 
right
so like
why worry
lol
if it was gigabytes in size i'd like. fix that
but it's not
idk!!! rust makes me very concerned about like memory optimization and stuff
you have nothing to worry about
why?
the point of rust is that you don't have to worry about that
because it does it for you
asterisk
it makes you do it for you
but there are still like ownerships
do you even know what an ownerships is
if you're looking out for every single byte, rust still memory leaks 
you should inline the json using bincode to store it efficiently
i’m the worst rust developer
it's okay
you're okay
you're going to get through this
you're going to include_str the json
and then parse it in a lazycell
and be happy and content with life
and not have to include the json alongside the binary
everyone starts somewhere
oh lazycell seems neat
yep
you can also use a lazylock/oncelock to have it in a static
which means it'll be globally accessible
((((((asterisk))))))
will it work like that tho
fn something() -> LazyCell<i32> {
LazyCell::new(|| {
println!("initializing");
92
})
}
println!("ready");
println!("{}", *something());
println!("{}", *something());
That'll create a new LazyCell on each call
argh
you want
static PARSED_JSON_THING = LazyLock::new(|| {
// code to parse json goes here
});```
and then just
use it
oh yeah was gonna ask if i should use static then
yop
something like
aha
static RAW_JSON: &str = include_str!("./servers.json");
static SERVERS: Lazy<Vec<Server>> = Lazy::new(|| {
serde_json::from_str(RAW_JSON).expect("Invalid JSON")
});
using once_cell
you could do i guess
should i do oncecell or lazycell 
neither
lazylock
oh theres another one ffs 
i thought u said lazycell at first
it's okay i'm tired
sorry im been old
oh
This type is a thread-safe
LazyCell, and can be used in statics. Since initialization may be called from multiple threads, any dereferencing call will block the calling thread if another initialization routine is currently running.
yop
alright lets try
good luck
thanks and thanks for the help yall i apprciate it a lot
of course
use linux
im too lazy to do partitions 
thats not a reason
i dont have any linux user friends irl 
wait actually i have one
but
uh
he used kali as his first linux os
im not sure i can trust him 
kali is just debian with preinstalled cybersecurity tools
showoff
why would anyone purposely install [windows] as their main os
no
cuz i already paid for it 
i would pay thousands not to use windows
i also (used to) pay for adobe
scrub 
it never happened if you never get caught
also like i recently saw how cheap adobe creative cloud and photoshop was here before adobe left and like jesus fucking christ it was SO CHEAP
i swear to god i'd be paying for it
"cheap"
well, if you're ever looking for someone to give your adobe money to instead of adobe
my wallet's open
wdym before adobe left
$9 a month
oh before they left russia
yop
sorry i need some designer clothes
wooow
rustc: associated static items are not allowed

oh nevermind
Yep, statics can only exist outside of impls
Mostly because it's unclear how it would interact with generic types I think
that should work i guess
if you care you can also optimize that further but idt you should lmao
trynna use it like that but it keeps saying rust-analyzer: no such field
enough optimization for me for today 
show full code?
it's a bit long but uh sure
??? does Pia have a SERVERS field defined on it??
yeah but you’re trying to put it in the struct lmao
if you just do SERVERS it tries to do SERVERS: SERVERS
yeah right no im being a dumbass rn and no its like your constructor(x,y,z)
omfg 
servers: SERVERS works now ty
i mean i could use username and password without explicitly writing the field name so
yea but this is more like behavior from js not C in terms of how it infers what field to put
it keeps importing SERVER from reqwest lmfao
requwuest UwU
do i convert this one into LazyLock<PiaResponse> or make it a reference (or a pointer?) and then handle the lifetimes?
duh rustc: cannot move out of static item SERVERSmove occurs becauseSERVERShas typeLazyLock<PiaResponse>, which does not implement the Copy trait
fuck am i even doing
serde macros when
for compile time json parsing
true
Cow<'static, PiaResponse>
🐮
If you want to support both static and runtime values without lifetime hassles
what about this
That doesn't allow values defined at runtime
i mean it wont change anyways or wdym
In other words, pointless to have the field at all, just use the static directly
idk i just want to like have a convenient way of getting servers
being able to do pia_instance.servers sounds more convenient than doing like use pia::SERVERS
SERVERS is more convenient than self.servers
alright then
@valid jetty is this
or 
just clone everything
@hoary sluice
ZOoter
🦅ly
why is it so colorful
u mean my prompt?
Prompts should be beautiful
i have previously considered becoming a shrimp farmer
but it is not economically sustainable
yeah but also code highlighting and i think like the palette in general
floppa breeding however
its catppuccin mocha
thing at the bottom is lualine
@deep mulch i cant work ~an hour before sunset because the sun goes through the holes in my blinds
this reminds me of those bugs in windows where it only crashes on tuesdays at 14:38 if you have notepad open with the text "foo" inside
elle will have a similar bug
i also cant work an hour after sunrise but i sleep till 1 pm anyways
hus
i wake up at sunrise
it is duh
do you live in yakutia
insanen
or a place with very wrong timezones
not really
no
kazan prob has smth like this
@hoary sluice will explode on August 15th, 2084
on MSK but much farther east
the sunset is at 9pm
yea thats normal
the sunrise is normal as well 
sunrise
so you have dawn the day before?
uhh idk
where are you
🤫
north.
hell
and probably no sun all day outside of summer
ur what
ham radio license
can you finally play country music in the car or something
how are they gonna know
direction finding
they cant teleport
do you also need a radio license for making an online radio / podcast
or only actual radio
how do they know if u have a license or not
dont worry just move to another state
actual radio
proper identification
so if u just make internet radio it doesn't matter
what
what's zt radio frequency
HF
ah yes high frequency, my favorite frequency
HF is 3-30 MHz
mf saying like that was him 
the entire of youtube is like this, flashy clickbait
love the guy
he uses an advantage 360 and nvim
@valid jetty any time i look at elle src its like those enterprise java programs
That's not a very nice thing to say
you have multiple structs for expressions and im trying to see how you return them as one type in the parser and your parser does a bunch of random stuff and the word expression isnt even used in the parser
whens the ellec rewrite to elle
Wednesday
Yeah that parsing is wack
let tokens = self.yield_tokens_with_delimiters(&[TokenKind::LeftCurlyBrace]);
let elif_condition = Statement::new(tokens, 0, self.body, self.shared).parse().0;
```
the structs become variants of AstNode
ive been saying parsing needs a refactor for a while
Untyped asts are terrible though
it hasnt been refactored basically at all ever since i first wrote it
its just hacks on top of hacks
the parser is huge and complicated
rewriting it is gonna be a big process
ill need to do it incrementally
Rewrite it to not be huge and complicated, then
the language is complicated lol
Not syntactically, from what I've seen
the syntax can get ambiguous to parse at times
Like what?
like for example, you have a unary expression, which needs to yield tokens until it sees some "stopping point" (things like end of stream, arithmetic tokens, etc)
~???
that expression may be a function call
~foo()
that function call may be wrapped and have an extra arithmetic operation applied to it
~(foo() + 1)
arithmetic tokens are one of the "stopping points", so suddenly you have to keep track of parenthesis nesting and not count it as a stopping point if nesting > 0
that function may be generic and have explicit generics passed in
~(foo<i32>() + 1)
again, arithmetic tokens are one of the "stopping points", which means that, because < and > are arithmetic tokens, you need to keep track of generic nesting. how do you do that, you need to lookahead after the < and see if the next token is a type
ok, what if the type is more complex??
~(foo<(i32, i32)>() + 1)
now you have to lookahead skipping certain tokens until you can ensure with certainty whether the < is used in an arithmetic or generic context and treat it differently accordingly
it quickly gets complicated, at least with the current way the parser is setup considering its handrolled
Ah, the Bastion
wha
what is this 😭
An example of why <> generics are inherently ambiguous
wait is that how rust deals with it
put :: before generics
lmao
i never thought about that
unfortunately not quite solves all the problems because of array literal shorthands
If you do generics with <>, there is no way to resolve the ambiguity in foo(a<b,c>(d))
!([Foo<i32>;]);
oh i see it
horror
Unless you do like c++ which knows at parse (or even lex? Not sure) time which identifiers are defined, so it knows that a is a template
i dont do that i only do that for struct and enum defs
But that leads to a very nasty chimaera of type checking and parsing
yeah
i was thinking that allowing for T x = y syntax is also inherently ambiguous unless you do heavy lookahead
It's very hard to do assignments unambiguously
because ```rs
fn(i32) -> i32
and ```rs
fn(i32 x) x * 2;
``` is a valid lambda
it can be ambiguous when you do ```rs
fn(i32) -> i32 x = fn(x) x * 2;
``` unless you lookahead far enough to see "oh, this has args, it must be a lambda def and not a lambda type"
In rust sin(x) and sin(x) = 0.5; are both valid but mean very different things
hence only looking for types in specific contexts instead of expecting them at any point
let x: ??? is unambiguous because you know 100% that youre parsing a type after the :
I don't know how rustc deals with that ngl
what is the second one
Unwrapping a newtype struct
isnt that specifically required to have let before it
Wait no since there's a float in the rhs that's not valid
/run ```rs
struct sin(f32);
let x;
sin(x) = sin(0.5);
@fleet cedar I received rs(1.68.2) compile errors
warning: type `sin` should have an upper camel case name
--> file0.code:2:8
|
2 | struct sin(f32);
| ^^^ help: convert the identifier to upper camel case (notice the capitalization): `Sin`
|
= note: `#[warn(non_camel_case_types)]` on by default
warning: variable `x` is assigned to, but never used
--> file0.code:4:5
|
4 | let x;
| ^
|
= note: consider using `_x` instead
= note: `#[warn(unused_variables)]` on by default
warning: value assigned to `x` is never read
--> file0.code:6:5
|
6 | sin(x) = sin(0.5);
| ^
|
= help: maybe it is overwritten before being read?
= note: `#[warn(unused_assignments)]` on by default
warning: 3 warnings emitted
Useful for fib and stuff ```rs
for x in 0..n {
(prev, cur) = (cur, prev + cur);
}
i think parsing tuple destructuring and tuple creation is also ambiguous
for now thats not a problem
because for me theyre different
x, y := $(z, w);
but that sounds like a pain to parse correctly
on that note
how does rust differentiate expressions and patterns in cases where either can fit
@hoary sluice wake up new sebastian lague video dropped
I don't know actually
Perhaps parses both the same and disambiguates later
A procedural programming language built in Rust and QBE - acquitelol/elle
the name is uhhh
not ideal
Wow your statement.rs is bigger than my whole lexer+parser+printer
but whatever
where do u call Codegen::compile
her statement.rs is almost triple the size of my entire codebase
function.rs: Line 108
statement.clone().compile(gen, &ctx);
that
ty
that is the root statement being compiled, any then the inner ones may each call compile themselves
compile itself doesnt really exist its a proc macro
At the very least, you'll almost always at least want separate stmt and expr types
yeah i know
technically speaking, every node is considered a "Statement" semantically (by name) though that means nothing because some of those nodes return None and some return Some((ty, val))
depending on if its actually an expression or statement
In other words, not all nodes are expressions
yes
because all expressions are statements but not all statements are expressions
so everything falls into the umbrella term "Statement" and then can potentially return a value
which isnt really how statements work but whatever
I don't know about elle specifically, but in most languages that is not true, at least
foo() is an expression, foo(); is a statement
i mean yeah i guess you can look at it that way
the program
fn main() {
1;
}
``` would have a single node which is a literal, that is a statement but it still yields a (ty, val)
Expressions can be embedded in statements, including as standalone, but statements (usually) cannot be embedded in expressions
terminology is.. not great here
Some languages do allow it with clever use of {} though
yeah thats what i was trying to say
i dont think theres ever a case where you dont
yeah i like gleam's usage of it
i was gonna only have expr at first but what does x + (foo = bar) mean
no need for parenthesis because you can use blocks to split things
or better yet x + (foo :: int int)
this is an expr which has a side effect of setting foo to bar and then returns x + bar
thats what it would do in elle
its not a variable assignment per se
x + (foo a b = a + b)
whats this
Declarations are the single thing in rust that are not expressions
well thats a problem with how you parse functions
tried to cast FunctionDeclaration to Int?
yeah
which is why i added statements
Only language I can think of without stmt/expr distinction is lisp
And that one's... yeah
i mean elle has a distinction between stmt/expr, its just not at the parser level
Well fix that then
yeah, once i rewrite the parser
the current one has worked well enough that i havent found a need to yet but as its gonna take a while ill probably do it during the summer holiday
wait fuck im supposed to be studying in that time
what is the value of (1 + (defun foo (a b) (+ a b)))
uhhhhhh idk when ill do it
a type conversion error
/run ```lisp
(1 + (defun foo (a b) (+ a b)))
@fleet cedar I only received lisp(2.1.2) error output
; file: /piston/jobs/71d5274c-5aaf-4dab-8a07-919e01f5292a/file0.code
; in: 1 +
; (1 + (DEFUN FOO (A B) (+ A B)))
;
; caught ERROR:
; illegal function call
;
; compilation unit finished
; caught 1 ERROR condition
Unhandled SB-INT:COMPILED-PROGRAM-ERROR in thread #<SB-THREAD:THREAD "main thread" RUNNING
{1001558103}>:
Execution of a form compiled with errors.
Form:
(1 + (DEFUN FOO (A B) (+ A B)))
Compile-time error:
illegal function call
Backtrace for: #<SB-THREAD:THREAD "main thread" RUNNING {1001558103}>
0: (SB-DEBUG::DEBUGGER-DISABLED-HOOK #<SB-INT:COMPILED-PROGRAM-ERROR {100158F6B3}> #<unused argument> :QUIT T)
1: (SB-DEBUG::RUN-HOOK *INVOKE-DEBUGGER-HOOK* #<SB-INT:COMPILED-PROGRAM-ERROR {100158F6B3}>)
2: (INVOKE-DEBUGGER #<SB-INT:COMPILED-PROGRAM-ERROR {100158F6B3}>)
3: (ERROR SB-INT:COMPILED-PROGRAM-ERROR :MESSAGE "illegal function call" :SOURCE "(1 + (DEFUN FOO (A B) (+ A B)))")
Well there you have it
where does it ever make sense for declarations to be expressions
/run ```lisp
(+ 1 (defun foo (a b) (+ a b)))
@fleet cedar I only received lisp(2.1.2) error output
Unhandled TYPE-ERROR in thread #<SB-THREAD:THREAD "main thread" RUNNING
{1001558103}>:
The value
FOO
is not of type
NUMBER
when binding SB-KERNEL::Y
Backtrace for: #<SB-THREAD:THREAD "main thread" RUNNING {1001558103}>
0: (SB-KERNEL:TWO-ARG-+ 1 FOO) [external]
1: (+ 1 FOO)
2: (SB-INT:SIMPLE-EVAL-IN-LEXENV (+ 1 (DEFUN FOO (A B) (+ A B))) #<NULL-LEXENV>)
3: (EVAL-TLF (+ 1 (DEFUN FOO (A B) (+ A B))) 0 NIL)
4: ((LABELS SB-FASL::EVAL-FORM :IN SB-INT:LOAD-AS-SOURCE) (+ 1 (DEFUN FOO (A B) (+ A B))) 0)
5: ((LAMBDA (SB-KERNEL:FORM &KEY :CURRENT-INDEX &ALLOW-OTHER-KEYS) :IN SB-INT:LOAD-AS-SOURCE) (+ 1 (DEFUN FOO (A B) (+ A B))) :CURRENT-INDEX 0)
6: (SB-C::%DO-FORMS-FROM-INFO #<FUNCTION (LAMBDA (SB-KERNEL:FORM &KEY :CURRENT-INDEX &ALLOW-OTHER-KEYS) :IN SB-INT:LOAD-AS-SOURCE) {10008A746B}> #<SB-C::SOURCE-INFO {10008A7433}> SB-C::INPUT-ERROR-IN-LOAD)
what the fuck
@fleet cedar I only received lisp(2.1.2) error output
you glaze and shill js
since when
not very often (and ts would catch this)
@lucid trail btw is your goal to make a full compiled language or?
i should make a programming language
You should make a progaming language
@valid jetty hiii
someday.
Yeah, compiled for sure. Not sure what it’s gonna look like though
are you only trying to get the top level stuff at root then
@valid jetty
format!("Unsupported operator: {:?}", self.node.operator.node.kind),
self.node.operator.node.kind
nested Located
why not just get items at directory then
you can do top level with enumerator but no point if you’re already doing the work on bg thread to then show it at once
i would use swift async for this
What does () even do
make a mainactor task that awaits value of a detached background task which does the filesystem work and returns rhe result
then use that in your ui
before awaiting the bg task maybe show a loading spinner
im on mobile but i can write example code if you want
test
i cant remember how to use enumerator to read top level files and dirs bc ive only ever used it once in meret
creating a directory with like 10k files in it
you’ll have to find out how to use it yourself
sorry oomf
no you have to do a thing at each iteration to not dive into a child
@young flicker @solemn ravine
SAME
🥺
do i win bc i have more
or do i lose bc thheres too many
@young flicker
would you believe me if i said it ran like shit
well it did
@young flicker
//
// View+AppPersistence.swift
// Meret
//
// Created by Lakhan Lothiyi on 20/03/2025.
//
import SwiftUI
public extension View {
/// Add this to the root of your app or something so it can receive preference changes from persist modifier.
func persistenceHandler() -> some View {
self.modifier(AppPersistenceHostViewModifier())
}
}
struct AppPersistenceHostViewModifier: ViewModifier {
func body(content: Content) -> some View {
content
.onPreferenceChange(AppPersistenceHostKey.self) { newValue in
UIApplication.shared.isIdleTimerDisabled = newValue
}
}
}
struct AppPersistenceHostKey: PreferenceKey {
static var defaultValue: Bool = false
static func reduce(value: inout Bool, nextValue: () -> Bool) {
value = value || nextValue() // combines all values, if any are true, return true else return false
}
}
public extension View {
/// Prevents the device from going to sleep while this view is on screen, or the value is made false.
/// All views with this modifer set to true will cause the device to not sleep. They need to all be removed to allow sleep.
/// - Parameter value: Whether to prevent sleep
func persist(_ value: Bool = true) -> some View {
self
.preference(key: AppPersistenceHostKey.self, value: value)
}
}
somehow not a swiftui feature
no idea what this is
if a view with the persist() modifier exists on screen it will not let the device autolock
i use it in ipod when the lyrics ui is open
i mean meret
I put it in appdelegate

horror bc it means u have to manage its state manually
though its fine for console app bc it will always be open
in my case meret should only keep phone awake when lyrics ui is open
instead of using on appear and on disappear, my modifier ensures the phone is only kept awake if the view exists and is guaranteed this way
@young flicker @solemn ravine
what did i do
@valid jetty remember when i tried changing my email from my school email to my personal email on all my repos
i did that and it unsigned all my commits
so i tried signing them with rebase
now https://github.com/eagely/eagely has every commit 27 mins ago 
LMAO
and thats the only repo i ran it on (other than another private, irrelevant one) which i didnt have saved locally
cause i just update it from github
not locally
is icypeas updated already
nah
idk how to sign all previous commits without changing their date
like there is a way but its scary
id rather just not sign
solution: 怖くないよ
uhm so this is just a lie
lol
infinite contributions glitch
i had like 200 before all these shenanigans
allegedly github has a gc that wipes orphned commits from the contribution graph so its prob gonna get fixed soon
i found one
git rebase --root --gpg-sign --committer-date-is-author-date
what do i use here? to_string? to_owned? another one?
also uh does it look fine
also im trynna make it so that if token somehow does not exist - it returns an Err
doesn’t result take T,E?
that's anyhow's Result
oh cool
yop
oh .get() returns an Option
@valid jetty i did it
and i dont think anything is too broken
all my commits are now signed and use my correct email
Does the github graph reflect it accurately?
nope
or is it doubled
its like 10x
im pretty sure that orphaned commits get garbage collected tho
cause i amend a lot and i cant find one where its duplicated because of an amend
or an undone commit
so im guessing github garbage collects this like once a week or smth
how do i fuckin get rid of Option i keep forgetting
idk why but it says rustc: unreachable call
@valid jetty when vibe coding elle
What is bail! ? I think unwrap_or replaces None with the provided value
@valid jetty https://neofetch.sh/
from anyhow
anyhow guhhhh idk anything about anyhow
does anyhow do anything besides adding context and bail!
idk i just use it cuz errors are annoying in rust
I probably wont be adding generics for a year but if i ever do Ill make the syntax foo[T]
good idea
.unwrap_or(return ...) unconditionally returns
bail!(...) is return Err(anyhow!(...))
you can put return in unwrap_or??
isnt return a statement???????
Return is an expression of type !
oh ok that makes sense actually
i was literally planning to do the same thing for my thing
insane
I'm thinking of using generational_arena for my AST nodes but having it all untyped is wack
I don't think this is very sane
Yeah that does not look like a particularly meaningful enum
should probably go use typed arena instead
Bumpalo is a popular choice
keep in mind that struct variants in sum types cannot be collected into a struct, you must destructure it
yeah that has been a bit annoying already
Fun fact: C++ does this with throw, but not return
maybe i should just do arena and not enforce type safety at that level
what the fuck is this
//
// Usage: SetThreadName ((DWORD)-1, "MainThread");
//
#include <windows.h>
const DWORD MS_VC_EXCEPTION = 0x406D1388;
#pragma pack(push,8)
typedef struct tagTHREADNAME_INFO
{
DWORD dwType; // Must be 0x1000.
LPCSTR szName; // Pointer to name (in user addr space).
DWORD dwThreadID; // Thread ID (-1=caller thread).
DWORD dwFlags; // Reserved for future use, must be zero.
} THREADNAME_INFO;
#pragma pack(pop)
void SetThreadName(DWORD dwThreadID, const char* threadName) {
THREADNAME_INFO info;
info.dwType = 0x1000;
info.szName = threadName;
info.dwThreadID = dwThreadID;
info.dwFlags = 0;
#pragma warning(push)
#pragma warning(disable: 6320 6322)
__try{
RaiseException(MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR), (ULONG_PTR*)&info);
}
__except (EXCEPTION_EXECUTE_HANDLER){
}
#pragma warning(pop)
}
why do i need to raise an exception to set the thread name
lmfao
Hey that's pretty cool
error recovery is somewhat difficult
My favorite strategy for error recovery is to pair delimiters during lexing
Admittedly gives poor recovery if said delimiters are mismatched, but once that's done, simple schemes like skipping to the end of the delim work surprisingly well
why does todo have an !? do you have macros?
@valid jetty there is no programming language called icy other than a 4-commit project on github with only a lexer
should i name it icy
tbh doing a loop for promise retry is pretty annoying
i can't really think of a better way
yeah but it says rustc: unreachable call
so how do i fix it 
Probably want .ok_or_else(|| anyhow!("invalid json response"))?
Or equivalently, .context("invalid json response")?
oh ok_or_else might be exactly what i need
arghhhhh
ok that worked lol
is it cursed or not
yay that works
Consider defining a struct for the response though
i mean the response is literally just
{
"token": "tokenHERE"
}
That makes a very simple struct then
@valid jetty is this horror
i tried making an Evaluate trait and splitting Expression into multiple structs but it got too complicated and i gave up
What's with all the evaluate_binary_plus et al?
That looks like it could be written with less boilerplate
ik
trait Evaluate {
fn evaluate(env: Env) -> Result<Value>;
}
struct UnaryExpression {
operator: Located<Token>,
expression: Located<Box<dyn Evaluate>>,
}
impl Evaluate for UnaryExpresson {
...
}
like this?
this is the cleanest way i can think of
Or just match (node.kind, self.force_eval(left)?, self.force_eval(right)?) { ... }
&& and || wouldn't work with that but doesn't look like you have those there anyway
Nope, it’s just there
huh
im talking about all expressions not just binary

yall made me want to make my own language but instead of a general programming language ill make a shell
lmao fair enough
@hoary sluice elle mirror on sourcehut https://git.sr.ht/~rosiepie/elle
@valid jetty https://rugplay.com
i made 3 alts and lost everything on coinflips
make that 4
internal server error
like this?
itd look so much better like this but glob imports are the devil apparently
Glob imports are fine if you use them sparingly
Using them just before a match is fine
The two issues with glob imports are that they make it a little harder to tell what's in scope (not an issue if it's in a small scope), and that if you remove or rename a unit variant, then EqualEqual can suddenly become a match-all pattern instead (but you get naming and unreachable pattern warnings in that case)
either way i have TokenKind::Integer and Value::Integer, if i glob both then its ambiguous, if i glob one of them then it looks ugly and is really just pointless because it wont become much more readable
and tbh this is already very short and maintainable
A good compromise is use TokenKind as T;
I'm on mobile so I can't see the code in question
A bit ugly that some of the arms have {} but others don't, but otherwise looks fine
well thats rustfmt
if i make it put {} everywhere then other match statements will be ugly
i dont like how it doesnt put {} around l.checked_operation
I'd probably glob import Value::* there
Fair enough
@valid jetty idea for elle
allow ? and ! as suffix for method names
- if rosie.isGay()
+ if rosie.gay?()
``` (you can also omit the parentheses)
```rb
array.sort() # copy
array.sort!() # in place

ruby / crystal do that
so good
That's a lisp thing
how do i google that 😭
i should learn crystal
it seems fun
not a bad idea but maybe specifically .? or .!
i wanted to make the ? and ! operators be:
x := y?;
if y.is_none() {
return y;
}
x := y.unwrap();
and
x := y!;
x := y.unwrap();
``` respectively
?? !!
Ah, the toy code operator
usa.good??() # false
can still be ambiguous to parse
usagi.good??() # true 🐇
@valid jetty hiii
true
or a combination of them
@valid jetty add elvis operator
i have it??
oh
Add some other famous musician operators too
it exists you can do x ?: y and it is the same as x ? x : y
the rosie operator
beatles.good_music:?() # false
omg yes
what would the rosie operator do
foo.bar 💔 🥀 ()
Be very cute
yop
yop
you always have to write crystal lang
ight can’t really find anything either. is it like something on language-level or just like a way to name things
it's just naming convention
? is for "questions" (booleans) and optional stuff
! is for destructive actions
was this not stabilized
@royal nymph sleep
nope its not
its naptime
#![feature(let_chains)]
#![feature(if_let_guard)]
interesting
/run ```cr
print "hi".blank?
print "hi".byte_at? 3
print "hi".byte_at 3
Here is your cr(0.36.1) output @royal nymph
Unhandled exception: Index out of bounds (IndexError)
from /piston/packages/crystal/0.36.1/share/crystal/src/string.cr:1203:8 in 'byte_at'
from file0.code:3:1 in '__crystal_main'
from /piston/packages/crystal/0.36.1/share/crystal/src/crystal/main.cr:110:5 in 'main_user_code'
from /piston/packages/crystal/0.36.1/share/crystal/src/crystal/main.cr:96:7 in 'main'
from /piston/packages/crystal/0.36.1/share/crystal/src/crystal/main.cr:119:3 in 'main'
from __libc_start_main
from _start
from ???
false```
oh so its just the difference between x[2] and x.get(2) in rust/elle
why did it error first lol
/run ```cr
puts "hi".blank?
puts "hi".byte_at? 3
puts "hi".byte_at 3 rescue print "byte_at exploded"
oh ic. also uh what do u use crystal for
Here is your cr(0.36.1) output @royal nymph
false
byte_at exploded```
rosiinga
cuz like crystal seems like an interesting simple language
sounds like a python alternative to me 
you can use crystal for whatever you want