|
you buffer the data that you are iterating over...
|
# ? May 17, 2012 19:39 |
|
|
# ? May 24, 2024 23:37 |
|
BonzoESC posted:lots of that is comment eh in groovy just use a closure code:
using exceptions as signals ala python seems wrong unless they have a distinct mechanism for truly exceptional error states?
|
# ? May 17, 2012 19:49 |
|
Internaut! posted:eh in groovy just use a closure groovy's a little better than that 5.times { println it+1 }
|
# ? May 17, 2012 19:56 |
|
ugh thats so grosssss
|
# ? May 17, 2012 20:04 |
Shaggar posted:ugh thats so grosssss shaggar was right
|
|
# ? May 17, 2012 20:19 |
|
Sulk posted:shaggar was right says sulk
|
# ? May 17, 2012 20:24 |
|
trex eaterofcadrs posted:groovy's a little better than that if we're golfing it, ruby: code:
|
# ? May 17, 2012 21:16 |
|
please don't tarnish ruby's deserved reputation for writing expressive, literate code by giving in to the byte jockeys and their love for needless optimisation and unreadable "clever" code
|
# ? May 17, 2012 21:18 |
|
eh assuming that reads "print all members of this set" that seems like good syntax to me
|
# ? May 17, 2012 21:29 |
|
Internaut! posted:eh assuming that reads "print all members of this set" that seems like good syntax to me it implicitly calls to_a (to array) on the range 1..5, expands it out into multiple arguments, and calls puts with them code:
|
# ? May 17, 2012 21:34 |
|
Internaut! posted:eh assuming that reads "print all members of this set" that seems like good syntax to me if you have to guess its bad syntax
|
# ? May 17, 2012 21:35 |
|
you are allowed to write cute code in your language if everyone else is doing the same thing. i.e. it is idiomatic. if "puts *(1..5)" is something you actually see often in "real" ruby code, then it's fine. i dont use ruby so my criticism doesnt count.
|
# ? May 17, 2012 21:39 |
|
Shaggar posted:if you have to guess its bad syntax i dont understand this language i dont use, a blo bloo bloo
|
# ? May 17, 2012 21:40 |
|
Shaggar posted:you buffer the data that you are iterating over... then you have to call has_next otherwise your code doesn't work, which is loving stupid, plus it means that anything that shows up between the call to has_next and next gets skipped
|
# ? May 17, 2012 21:42 |
|
no i understand it. its just bad syntax
|
# ? May 17, 2012 21:43 |
|
yaoi prophet posted:then you have to call has_next otherwise your code doesn't work, which is loving stupid, plus it means that anything that shows up between the call to has_next and next gets skipped of course you would call has_next, because you want to see if theres stuff available. not calling it would be idiotic. and anything that comes in between has_next and next is put at the end of the buffer in the order it came in. i mean, unles you're using really dumb poo poo like python where you can assume it does something horribly wrong.
|
# ? May 17, 2012 21:44 |
|
although lets be honest an iterator is completely the wrong thing to use in that situation.
|
# ? May 17, 2012 21:47 |
|
i fully expect these multiple statements in my high level language, possibly separated by control flow, to be atomic
|
# ? May 17, 2012 22:06 |
|
Shaggar posted:of course you would call has_next, because you want to see if theres stuff available. not calling it would be idiotic. and anything that comes in between has_next and next is put at the end of the buffer in the order it came in. i mean, unles you're using really dumb poo poo like python where you can assume it does something horribly wrong. or instead of loving around with a buffer you could just throw an exception
|
# ? May 17, 2012 22:12 |
|
JawnV6 posted:i fully expect these multiple statements in my high level language, possibly separated by control flow, to be atomic i want them to be useful, and it turns out that you can either not share anything (the right way) or use a bunch of janky ('cause they're easy to gently caress up) locking constructs to make them useful
|
# ? May 17, 2012 22:33 |
|
lock bt[rs]l ought to be enough for anyone
|
# ? May 17, 2012 22:45 |
|
JawnV6 posted:lock bt[rs]l ought to be enough for anyone anyone meaning implementors of compilers erlang/otp supremacy
|
# ? May 17, 2012 22:47 |
|
thought #lock cmpxchg8b was the lock hotness du jour
|
# ? May 17, 2012 22:56 |
|
at the circus for a clown to use
|
# ? May 17, 2012 23:00 |
|
you guys are arguing with shaggar. just fyi. didnt know if maybe you have usernames turned off or something
|
# ? May 17, 2012 23:02 |
|
JawnV6 posted:at the circus clownOS
|
# ? May 17, 2012 23:04 |
|
JawnV6 posted:at the circus
|
# ? May 17, 2012 23:09 |
|
yaoi prophet posted:or instead of loving around with a buffer you could just throw an exception lol ya lets both use iterators for io and not buffer io - an idiot (aka python user)
|
# ? May 17, 2012 23:22 |
|
BonzoESC posted:i want them to be useful, and it turns out that you can either not share anything (the right way) or use a bunch of janky ('cause they're easy to gently caress up) locking constructs to make them useful eh I look at actors in erlang/scala/clojure/etc and without looking too closely I know if they're both easy and foolproof there must be a catch and it's almost certainly performance
|
# ? May 18, 2012 00:13 |
|
Tiny Bug Child posted:yeah strong typing rules i totally want my code to have more errors
|
# ? May 18, 2012 00:32 |
|
Internaut! posted:eh I look at actors in erlang/scala/clojure/etc and without looking too closely I know if they're both easy and foolproof there must be a catch and it's almost certainly performance it probably is performance but the erlang app i work with is i/o bound not cpu bound so it's not that important
|
# ? May 18, 2012 00:34 |
|
if you are iterating over something that's simultaneously changing while you're iterating over it then an iterator is probably not exactly the tool you want. no commonly used I/O system lets you send something to someone and then subsequently change your mind and un-send it. also if you really wanted to abuse iterators for I/O (let's make these completely different things look exactly the same) then you'd probably make next() block or something and only make has_next() return false on EOF. if it isn't changing while you're iterating over it then constant data can't very well have a race condition can it (please don't bring up concurrent splay trees or something stupid like that) C++ (ew) makes iterators pointer-shaped. Java's iterator interface uses hasNext() and next(). Literally every other imperative language with iterators manages to do this just fine without needing to use nonlocal jumps. Stop making up ridiculous contrived what-if cases to justify this design decision please.
|
# ? May 18, 2012 03:00 |
|
Mr Dog posted:also if you really wanted to abuse iterators for I/O (let's make these completely different things look exactly the same) then you'd probably make next() block or something and only make has_next() return false on EOF. these are kind of the same thing though and it enables some cool stuff! the "rack" http server protocol for ruby only requires that the response body respond to "each" and yield only String values to the block passed in to each this means that regardless if your app is going to respond with "butts" or if it's going to stream a thing over a network you don't have to have the upstream app server know what's coming out (in the first case, the array of one string ["butts"]; in the second case, some kind of TCPSocket) or necessarily have your app buffer things think of it as a duck-typed http://docs.oracle.com/javase/6/docs/api/java/io/Reader.html
|
# ? May 18, 2012 03:06 |
|
in java low level inputstreams bring in raw bytes so u can just read them in (buffered or not) and throw them up to something smarter to figure out what they are. although idk why you'd want a webserver that can read http but then also read some random protocol (on the same socket) like you're talking about?
|
# ? May 18, 2012 03:44 |
|
nerds
|
# ? May 18, 2012 04:19 |
|
Shaggar posted:you buffer the data that you are iterating over... code:
|
# ? May 18, 2012 06:02 |
|
my carefully constructed (contrived) edge case completely invalidates your tip that works most of the time
|
# ? May 18, 2012 06:06 |
|
fuuuuuuuuuuuck.. holy shiiiiit piiisssss
|
# ? May 18, 2012 06:54 |
|
tef posted:you call next() repeatedly until there is an error finding the end of an array is an exceptional condition
|
# ? May 18, 2012 15:39 |
|
|
# ? May 24, 2024 23:37 |
|
lists end?!?. wait up here
|
# ? May 18, 2012 15:40 |