devyn changed the topic of #elliottcable to: 22:53:14 <+whitequark> also there was a fragment about Swiss embassy being located on top of a 1000-ft pole, inside which there was a gigantic arms exhibit
<devyn>
linux's container_of() macro is brilliant
fwg has quit [Ping timeout: 246 seconds]
<whitequark>
it's pretty horrible though
<whitequark>
y u looking at linux?
<devyn>
looking at how they do rbtrees
<devyn>
and it's not even really necessary in this case
<devyn>
(container_of)
<devyn>
they use it anyway but really you don't need to
<whitequark>
I actually wonder if this is legal
<whitequark>
because I'm pretty sure this violates C aliasing rules
<whitequark>
"A pointer value is associated with the addresses associated with any value it is based on."
<whitequark>
my brain hurts.
<whitequark>
but it seems that yes, that kind of hackery is indeed legal.
<devyn>
anyway, it isn't really necessary in rbtree's case; if the node struct is the first member of your container struct, then you should just be able to cast
<whitequark>
right, it's basically the same case as &arr[1] - 1
<whitequark>
that is legal, so container_of should be legal too
<whitequark>
... I think.
<devyn>
...yes I think that makes sense
<whitequark>
time to join ##c!
<whitequark>
(not actually)
<devyn>
from what I've heard of ##c, someone will immediately beat you over the head and verbally abuse you for not knowing, and tell you to RTFM
<devyn>
and then maybe if you're lucky, and hour later someone nicer will come along
<alexgordon>
...and that person will be elliott
<alexgordon>
O_O
<ELLIOTTCABLE__>
D'awwwww
<alexgordon>
HOLY SHIT IT'S THE PROPHET
<whitequark>
devyn: you see, I would have no problems doing the exact same thing back, toghether with an incorrect interpretation of the standard
<devyn>
heh
<alexgordon>
I still don't understand what container_of does
<alexgordon>
and I just read two articles about it
<whitequark>
which will hopefully enrage the other party either until they have a stroke, or to the point when they actually explain shit
<ELLIOTTCABLE__>
Love you too, alexgordon
<whitequark>
alexgordon: struct { int x; int y; } s;
<whitequark>
given &s.y, get &s
<alexgordon>
ah
<devyn>
alexgordon: if you have a struct, and its contained in memory within another struct, container_of will give you the container struct by subtracting the offset
<devyn>
and casting
<joelteon>
that's cool
<alexgordon>
whitequark: this immediately begs the question: why, just why?
<whitequark>
devyn: that was too many words
<devyn>
because kernel
<devyn>
whitequark: heh
<whitequark>
alexgordon: because you can then pass one pointer
<alexgordon>
why not pass the outer pointer -_-
<whitequark>
that would not violate the abstraction
<whitequark>
too clean :p
<alexgordon>
haha
<whitequark>
actually though, linux has a lot of uses of the pimpl pattern
<alexgordon>
also I too thought this was illegal
<whitequark>
you know what that is, right?
<devyn>
alexgordon: in the case of rbtree, it allows it to be implementation-independent, so the rbtree handling code just handles what it knows, and gives you what it knows, and then you get what you need from outside of it
<devyn>
although... container_of is really not necessary
<whitequark>
so container_of allows you to get the public wrapper based on just the private implementation
<whitequark>
it's pretty tame actually, there is an 1:1 correspondence between those two
<whitequark>
always
<devyn>
yeah
<whitequark>
well, tame in kernel context
<alexgordon>
remind me never to write a kernel
<alexgordon>
or at least, not in C ;)
<whitequark>
don't ever do that
<devyn>
I am doing that :(
<alexgordon>
write a kernel in C, write a kernel not in C, or either?
* whitequark
goes back to figuring out how to write a kernel in rust
<alexgordon>
OMG GUYS. FURROW. KERNEL
<alexgordon>
lulz
<alexgordon>
slightly less insane than a haskell kernel
<devyn>
lol
<purr>
lol
<alexgordon>
at least there's no GC :P
* devyn
coughs
<devyn>
House
<whitequark>
alexgordon: haskell kernel has been done
<alexgordon>
cuttle: I am the king of comic sans, and syntax
<joelteon>
i'm the king of carrot flowers
<alexgordon>
cuttle: that must be the least trusthworthy thing I've ever said
<ELLIOTTCABLE__>
comic sans tax
<cuttle>
hahaha
<cuttle>
ok so I want to design a syntax for multimethods
<cuttle>
I don't want it to look like ruby or io with a.f(b, c) because that privileges the first argument
<cuttle>
I don't want it to look like lisp, but I'm holding out hope for something that doesn't look like f(a, b, c) and ideally doesn't syntactically privilege infixes
<cuttle>
I should probably give up on the non-privileged infixes but
<cuttle>
I kind of want something other than f(a, b, c)
<cuttle>
like, a postfix/infix thingy like smalltalk
<alexgordon>
ah, interesting
<alexgordon>
well
<alexgordon>
how about picking a special case: bimethods first
<alexgordon>
then extrapolate a solution to n-ary methods
<alexgordon>
bimethods sounds kinky
<cuttle>
lol
<purr>
lol
<joelteon>
whats a multimethod
<alexgordon>
like I always think about zip
<cuttle>
joelteon: you know how when you have a class A with a method f, and B and C subclass A and override f
<joelteon>
yes
<cuttle>
then b.f() and c.f() call different methods
<joelteon>
yes
<alexgordon>
([1, 2, 3], [7, 8, 9]).zipWith(f)
<cuttle>
well, in effect, f has one argument, and there are 3 versions of f, and a runtime decision is made based on the type of f's argument
<alexgordon>
is a shit syntax
<cuttle>
well, what if you write it like this
<cuttle>
f(a) instead of a.f()
<cuttle>
and then you extend that to multiple arguments
<cuttle>
and classes Y and Z extend class X
<cuttle>
and you have f(b, y) and f(c, z) and the other two combinations
<cuttle>
and those are all different versions of f that are chosen at runtime
<cuttle>
based on the argument types
<cuttle>
alexgordon: right yeah
<cuttle>
I like [1, 2, 3] zipWith(f) [4, 5, 6]
<cuttle>
which is basically APL/J/etc.
<cuttle>
although zipWith is implicit, but there are adverbs that go in the middle like that
<alexgordon>
though I suppose the real solution is
<alexgordon>
f.zipWith([1, 2, 3], [4, 5, 6])
<cuttle>
hm
<alexgordon>
ok how about something else
<cuttle>
i want an unordered smalltalk keyword arguments thing
<cuttle>
devyn: since in J, 1 2 3 +/ 4 5 6 is literally a thing
<devyn>
yeah I know
<cuttle>
ok :p
<alexgordon>
so in mathematica
<alexgordon>
inner(f, xs, ys, g) = fold f $ zipWith g xs ys
<alexgordon>
?
<joelteon>
heh
<joelteon>
wordpress is pretty bad
<joelteon>
are there any decent, moron-usable blogging engines that aren't wordpress
<alexgordon>
wait it's the other way around
<alexgordon>
stupid mathematica, I'm always getting this wrong
<alexgordon>
inner(g, xs, ys, f) = fold f $ zipWith g xs ys
<alexgordon>
in my pseudo-haskell
<alexgordon>
anyway point is, this is ideal for your syntax example cuttle
<alexgordon>
because there's actually two members of each type
<alexgordon>
two functions, and two lists
<devyn>
though really... why not just allow as many args on either side, like 1 2 3 [[zipWith] f] 4 5 6 or something
<alexgordon>
I've always wanted to make a language where . wasn't the only combinator
<alexgordon>
e.g. you have
<alexgordon>
f(x)
<alexgordon>
but you can also do
<alexgordon>
x.f()
<alexgordon>
right?
<alexgordon>
ok but then you have other things like . for map, fold, filter, etc
<alexgordon>
e.g. x./f for map
<alexgordon>
x.?pred for filter
<devyn>
honestly alexgordon just go learn J
<cuttle>
haha
<alexgordon>
devyn: fuck languages without infix notation
<cuttle>
alexgordon: j is entirely infix
<cuttle>
alexgordon: every function is both prefix and infix
<alexgordon>
does it have precedence?
<cuttle>
no
<alexgordon>
fuck it
<cuttle>
everything is right associative
<alexgordon>
I copy and paste equations from google
<alexgordon>
I expect it to *work*
<devyn>
really, who does that
<cuttle>
quitely honestly I'd prefer my ideal syntax to have no precedence
<alexgordon>
2*3+4*5 is 26 god fucking dammit
<cuttle>
either infix is privileged or there's no precedence
<devyn>
I try to avoid patterns like 2*3+4*5
<alexgordon>
devyn: my reaction to that: "silly programmers."
<devyn>
or if it really does look cleaner I'll write it 2*3 + 4*5
<alexgordon>
if there's one thing I know, it's that mathematicians are smarter than programmers (except haskell programmers who are mathematicians)
<alexgordon>
and *they* use precedence and infix notation
<alexgordon>
so there must be something to it. if it was a problem, they would use something else
<devyn>
ok I'll admit to using precedence and infix notation in haskell
<devyn>
:p
<cuttle>
alexgordon: mathematicians aren't smarter than programmers when designing machine-parsable syntaxes
<devyn>
I still think predecence rules should be minimal
<alexgordon>
not only mathematics though. pretty much every human written language
<alexgordon>
I feel that precedence and infix is very "human"
<alexgordon>
english isn't stack based
<cuttle>
alexgordon: also the first mathematican who designed a syntax was Ken Iverson who got us APL
<cuttle>
and removed precedence
<cuttle>
so there you go
<alexgordon>
cuttle: yeah but I bet all his mathematics papers still used infix notation
<devyn>
alexgordon: well there are languages that are much less dependent upon such things
<alexgordon>
devyn: true
<devyn>
and they're generally considered to be less ambiguous
<alexgordon>
like chinese
<devyn>
mandarin is still SVO
<alexgordon>
it still has less structure than european languages
<devyn>
structure, done right, generally removes ambiguity...
<alexgordon>
nah
<alexgordon>
no!
<cuttle>
alexgordon: because they're *papers* :p
<alexgordon>
cuttle: i.e. more important than APL :P
<devyn>
alexgordon: unless you mean structure as in fixed places for things, in which case I agree
* cuttle
sighs
<cuttle>
I love math, I'm fucking majoring in math
<alexgordon>
devyn: structure as in words must be uttered in a specific order
<cuttle>
but "more important"
<cuttle>
it's meant to be read and understood by humans
<devyn>
alexgordon: ah, yes, okay, never mind then
<alexgordon>
cuttle: it was a joke
<cuttle>
ok
<cuttle>
lol
<purr>
lol
<alexgordon>
devyn: it's actually pretty cool how humans can get stuff from context
<devyn>
alexgordon: honestly I'd say Japanese is less dependent upon order... there's still a conventional order, but really it's all tagged so it shouldn't matter too much, and passive form and such are all explicit
<alexgordon>
but some languages rely on that more than others
<devyn>
Chinese, being SVO, relies on the whole infix thing
<devyn>
well mandarin
<devyn>
classical chinese is SOV
<alexgordon>
yeah maybe japanese is a better example
<alexgordon>
though it has different structure to it
<alexgordon>
japanese is a hard fucking language
<cuttle>
japanese is very easy
<devyn>
everything is extremely regular though, and explicit
<devyn>
so not really hard
<alexgordon>
once you master the three alphabets, the words, the grammar and the culture, sure
<cuttle>
the writing system isn't easy
<cuttle>
well, the smaller two are very easy
<cuttle>
the grammar is the fucking simplest thing ever
<alexgordon>
oh I forgot pronunciation
<cuttle>
pronunication is also very easy
<devyn>
the writing system and pronunciation of Mandarin are way harder lol
<purr>
lol
<cuttle>
much smaller phonemic inventory and simpler phonotactics than most languages
<devyn>
Japanese actually yes, has a very small phonemic inventory
<alexgordon>
cuttle: even if japanese is easy, speaking japanese *without offending everybody* is harder
<cuttle>
shouldn't really say "most" but most european for instance
<cuttle>
and I would disagree with that too
<alexgordon>
unless you're a rich old man, then it doesn't matter
<cuttle>
formality isn't much harder than most languages
<cuttle>
back me up here devyn
<cuttle>
there are certainly more conjugations and titles and shit
* devyn
backs up cuttle
<cuttle>
but that's like
<devyn>
it's actually easier because it's so explicit
<cuttle>
at the pronoun stage of learning the language
<alexgordon>
devyn: well you're canadian
<alexgordon>
americans don't give a SHIT about offending people
<devyn>
you're not american
<alexgordon>
they just say what's on their mind
<alexgordon>
well yeah, brits are worse than canadians in that respect
<alexgordon>
at least english people, the welsh don't give a shit either
<alexgordon>
ok, maybe southern english people
<devyn>
I don't know; we line up for buses and thank the bus driver and such
<cuttle>
so do we
<cuttle>
...
<cuttle>
lol
<purr>
lol
<alexgordon>
lol not what I mean
<alexgordon>
like I always have to worry about whether I'm saying something someone wants to hear?
<alexgordon>
it's rude to disagree
<alexgordon>
but americans don't care..
<alexgordon>
it's like they don't know the *rules* to disagreeing with someone
<devyn>
not sure whether it's because Americans, but I basically made that exact point on reddit and I got downvoted to hell
<alexgordon>
:D
<cuttle>
not quite sure what you mean
<alexgordon>
cuttle: ok so like if you said "I'm going to study art history"
<alexgordon>
cuttle: I can't say "I think art history is a poor choice"
<alexgordon>
even if that's what I think
<alexgordon>
I have to say something like "art history sounds fun, blah blah blah"
<devyn>
well, I'd probably also ask them why they want to study art history
<cuttle>
alexgordon: I feel like that's not at all a difference between uk and us
<devyn>
that's perfectly non-offensive
<devyn>
cuttle: yeah I don't think it's a difference
<cuttle>
alexgordon: everyone here feels obligated to say "art history sounds fun blah blah blah" and most do
<cuttle>
there are always rude people who say the previous
<alexgordon>
cuttle: it's hard to describe then
<cuttle>
but that's more of an aspergers or general asshole thing
<cuttle>
than american
<alexgordon>
but americans are more sincere and more abrupt
<alexgordon>
every american I've talked to has been this way
<alexgordon>
british people will lie to your face, to not hurt your feelings
<cuttle>
:/
<alexgordon>
funny thing is, I can't work out which way is better
<alexgordon>
talking to americans is more stressful for sure, because you never know when they're going to turn your worldview upside down when you were just trying to have a nice chat
<devyn>
haha
<alexgordon>
on the other hand, never ask a british person for advice
<joelteon>
like i'm going to follow that advice
<devyn>
honestly I don't think it has all that much to do with culture on a national level
<devyn>
it's more localized than that
<alexgordon>
devyn: yeah, like I said it's more associated with south england
<devyn>
well the US is really goddamn gigantic in both population and land mass
<devyn>
and there are so, so many different subcultures
<cuttle>
alexgordon: do you talk to most americans over irc
<cuttle>
alexgordon: or in real life
<cuttle>
because I would agree that *people on irc* may turn your worldview upside down when you're just trying to have a nice chat
<cuttle>
lol
<purr>
lol
<alexgordon>
cuttle: by virtue of not living in america, I talk to most americans on IRC
<devyn>
oh that's why then
<cuttle>
see, that's about the worst sample set you can have
<alexgordon>
cuttle: but I was talking about real people
<devyn>
the internet can turn anyone into an argumentative dick
<alexgordon>
no really, americans in real life are like this
<devyn>
some *people* are like that, but I'm not sure it has anything to do with being american
<devyn>
and then the rest is just cognitive bias
<cuttle>
well I notice a very large difference between the argumentativeness of irc and real life and I live in america
<alexgordon>
cuttle: yeah even english like me turn into argumentative dicks on IRC
<alexgordon>
asking vs something else (intuiting?)
<alexgordon>
a bit like high and low context cultures
<devyn>
pff forget culture, Japanese is a high-context *language*. I swear half the sentences people tell me are just <modified verb> and that's it, and maybe an object
<alexgordon>
but I love that
<alexgordon>
the more I learn about linguistics, the more I feel that English is a pile of crap
<alexgordon>
look at how many words that sentence required
<alexgordon>
it should just be
<devyn>
except when you actually need context, Japanese is horrible; the syllable count is just too damn high
<alexgordon>
"as I learn more linguistics, I feel english crap"
<cuttle>
alexgordon: entropy per second in speech or whatever tends to be constant between languages
<cuttle>
probably reduces to the speed of thought
<alexgordon>
cuttle: right but in terms of elegance, less words = better