These are chat archives for arenanet/api-cdi

30th
Jan 2018
Archomeda
@Archomeda
Jan 30 2018 02:06
oh, another thing i forgot, there's still the guild upgrades that aren't in the api yet
darthmaim
@darthmaim
Jan 30 2018 09:25
oh, new items got whitelisted
but 81996,81997,79734,81093 probably shouldn't be in there
I turned off the manual whitelist step
Edgar Doiron
@Coffee4cr
Jan 30 2018 18:07
lol problem solved!
yeah. expect a bunch of immediate-type items to start coming through.
the names/etc of those aren't actually displayed in-game
windwarrior
@windwarrior
Jan 30 2018 19:27
you mean items that autoconsume on obtain?
yeah
they're used for a lot of weird things
windwarrior
@windwarrior
Jan 30 2018 19:31
content
as long as the API doesn't start leaking everything is fine
rather too much exposed (like garbage items), than too little
windwarrior
@windwarrior
Jan 30 2018 20:42
[Just a side discussion] When styling code that chains filters, maps and reduce it is very common to go over 80 character line width
For example:
let content_list = considered_devs.map(x => x.content).reduce((accum, x) => accum.concat(x), []);
is already 98 chars
how would you format these longer chains
especially with less trivial lambdas
David Reeß
@queicherius
Jan 30 2018 20:46
I do it like this:
let content_list = considered_devs
  .filter(x => x.content)
  .map(x => {
    // this is a more complex lambda
  })
  .map(moreComplexFunction)
  .map(x => x.content)
  .reduce((accum, x) => accum.concat(x), [])
windwarrior
@windwarrior
Jan 30 2018 20:52
Yeah, what I don't really like is that the continuation on line 1 is easily missed and that it uses much vertical space. I tried it like this, but thats even worse:
let content_list = considered_devs.filter(
    x => x.content
).map(x => {
    // this is a more complex lambda
}).map(
    moreComplexFunction
).map(
    x => x.content
).reduce(
    (accum, x) => accum.concat(x), 
    []
)
David Reeß
@queicherius
Jan 30 2018 21:00
I feel like it's farily obvious with the continuation tbh. Also when you have all the dots below each other you know that it's getting chained, so you can just go through, read the first keyword and know "ok, filter, then map, then another map, then reduce" for example
But maybe I am just too use to it at this point, i dont know. /shrug
That said, something like this is not what I do:
// No, way too long to realize something is going on after that
let content_list = superComplexFunction(with, a, bunch, of, variables, {and: {random: {options: true}}}).data.inner.lol
  .filter(x => x.asd)

// Yes
let content_list = superComplexFunction(with, a, bunch, of, variables, {and: {random: {options: true}}}).data.inner.lol

content_list = content_list
  .filter(x => x.asd)
windwarrior
@windwarrior
Jan 30 2018 21:02
Python forces a \ on all lines I think for continuations
but python somehow defined map as a standalone function that takes iterables instead of as a function of iterable things
e.g. map(func, list) instead of list.map(func)
David Reeß
@queicherius
Jan 30 2018 21:04
That is weird :D
windwarrior
@windwarrior
Jan 30 2018 21:05
yeah that makes sense @queicherius, you can also split filter/map/reduce operations to new chains
I want Haskell's $ operator in all languages please
darthmaim
@darthmaim
Jan 30 2018 21:10
haskells . operater is where its at. $ is just to skip some brackets
also javascript has the |> operator which can help
windwarrior
@windwarrior
Jan 30 2018 21:11
how do I google that
darthmaim
@darthmaim
Jan 30 2018 21:11
"javascript pipe operator"
i guess
windwarrior
@windwarrior
Jan 30 2018 21:12
oh cool, I did not know that
oh is a draft
darthmaim
@darthmaim
Jan 30 2018 21:13
yeah :(
windwarrior
@windwarrior
Jan 30 2018 21:13
its called the pipeline operator
David Reeß
@queicherius
Jan 30 2018 21:17
@windwarrior I think Style 1 is the most common, Style 2 looks ackward to format (at least my IDE cant do that I think) and a pain to reformat when you change the var name, Style 3 seems reasonable, Style 4 is the same as style 2 in my eyes, just even more weird
windwarrior
@windwarrior
Jan 30 2018 21:17
:D
I was just trying out stuff, I have secretly already adopted Style 1 in the offending file
David Reeß
@queicherius
Jan 30 2018 21:19
prettier reformats it to style 1
windwarrior
@windwarrior
Jan 30 2018 21:19
The benefit for me of style 4 over 2 (even though they are both weird) is that the continuation is more obvious ("Hey I see an = without right hand side")
David Reeß
@queicherius
Jan 30 2018 21:19
Yeah that's fair
@darthmaim That pipe operator looks pretty cool, esp for functional programming
darthmaim
@darthmaim
Jan 30 2018 21:22
idd
David Reeß
@queicherius
Jan 30 2018 21:23
@windwarrior You could do this too:
let content_list = 
  considered_devs
    .map(x => x.content)
    .reduce((accum, x) => accum.concat(x), []);
But even more vertical space :D
windwarrior
@windwarrior
Jan 30 2018 21:23
formatting code is hard
Archomeda
@Archomeda
Jan 30 2018 21:24
there also seems to be a proposal for simplifying javascript's this binding
came across that the other day
windwarrior
@windwarrior
Jan 30 2018 21:27
every style looks weird to me now
thats maybe a sign that I have looked enough to formatting
back to figuring out redux
probably more fun
Archomeda
@Archomeda
Jan 30 2018 21:31
i do mostly style 1
David Reeß
@queicherius
Jan 30 2018 21:32
I ended up just using whatever style an automatic formatter can spit out, in this case prettier
Archomeda
@Archomeda
Jan 30 2018 21:32
with a bit of mixing style 3 into it
but i still use 4-space indentation :P
windwarrior
@windwarrior
Jan 30 2018 21:33
VS code format did nothing to prevent long lines :/
Werdes
@werdes
Jan 30 2018 23:51
VS (the real vs at least) encourages style 1 by just indenting following lines of an unfinished statement by a tab-space. looks easiest to maintain as well
2 and 4 look like a pain to format and 3 looks way too spacy for me (may be useful at // this is a more complex lambda though)