« first day (833 days earlier)      last day (2638 days later) » 

12:11 AM
@Shepmaster Hmm...
 
NO
YOUR RONG
^_^
 
... Problem, Shep?
 
Thought you were going to argue.
Was trying to shut that down ;-)
 
I would, but my rong is fine.
You seem to not be in the mood to back your statement. Maybe later then. I could also try and see what other projects do. Later.
 
haha, I'm in an OK mood
Just bein' silly
I certainly prefer it
and I'm pretty sure that's what I've seen the most
But I dunno if I can point to a "real" reason it should be at the end
I'd say that it would feel strange to have it before use and extern crate lines
 
12:17 AM
I put mine at the bottom because I prefer to see the actual running logic first when I open a file
rather than scroll down past all the tests
 
and then having an indented chunk in the middle of the file would be strange
@SimonWhitehead same here; but I can see the argument that the tests should explain the code
thus placing them first would be the better choice
Almost, but not the same as, literate programming
 
fair - I guess I could also be tuned into that way of thinking because of some C# setups I've seen.
where the tests are at the bottom (or more generally, in separate files altogether)
 
Yeah, Ruby does unit and other tests in separate files as well
 
I honestly wasn't thinking of writing the test module before extern crates and uses... Rather, just right after those. :)
Heck, let's put it in the middle. It's already the center-piece in TDD, so why not.
 
12:21 AM
@E_net4 there's also the possibility of eschewing the module altogether
 
just do some outside-in "spike-through" TDD - just spread the tests in between each function :P
 
and just writing tests after each function
 
@Shepmaster Indeed. I believe diesel does that.
 
 
3 hours later…
3:02 AM
quick question from a new guy: if I've got some impl method that takes mut self, how should i call another method that also takes mut self? e.g. fn a(&mut self) { b(self) } fn b(&mut self) { ... }
in other words, how do i allow the inner method call to borrow mut self?
 
self is already a mutable reference at that point.
so you can just call the method as normal.
that is: fn a(&mut self) { self.b() }
 
@SimonWhitehead Sorry, I think another language crept in there with the b(self) business – I did mean self.b(). Would it help if I posted what I have?
 
sure, you can post what you have if you want
 
@SimonWhitehead Oh, neat – I didn't know that could be used for sharing, too.
I've added what I had to your gist.
 
You'll have to send me a link
I can't see it otherwise.
 
3:08 AM
@SimonWhitehead Ah, gotcha. play.integer32.com/…
The only reason the lifetime parameters are there is because rustc wanted them
 
yeah you will need it for the &str references
 
<3 Using my playground
 
@Shepmaster I use it for the VIM key config :D
I always type jjjjjjjkkkkklllll into the official playground
and its so frustrating
 
I'm starting to think that the hello world of rust is to write a tokenizer
2
 
@Shepmaster Actually I'm going through mal in a new language
 
3:11 AM
@SimonWhitehead please keep using mine (it has crates!), but the official one also has vim bindings available
 
oh really? I didn't know that. I use yours anyway for the crates - its super helpful when trying to help people :D
 
@SeanAllred gotcha. But you are making a tokenizer nonetheless ;-)
 
@Shepmaster indeed – if I ever get it to compile! :)
 
@SeanAllred May I suggest just iterating over the vector instead of your manual next method?
 
@SimonWhitehead I thought I needed my next method to populate the vector?
 
3:15 AM
now I read it I'm not 100% sure what its doing - thats probably because you've stripped it down to an example.
but it seems to iterate over tokens, then push the token... to tokens.
that is, it seems like you're modifying the collection as you iterate over it
 
@SeanAllred do you understand why modifying self.tokens while holding a reference to something within self.tokenscould lead to Bad Things?
 
@SimonWhitehead Nope, that's not what I intended to write – I shouldn't be reading self.tokens anywhere yet
@Shepmaster Oy, yes. Iterator invalidation it's called, yes? I forget the names to these things; they get replaced with massive red flags.
 
@SeanAllred Yep, I'm glad you understand that. The next piece of the puzzle is the fact that Rust evaluates things based on function boundaries
 
@Shepmaster would I be correct in calling that lexical scoping or are we talking about something else?
 
So when you call fn next(&mut self), that says "This method might mutate self in such a way that any reference I have to the insides of self might become invalidated"
 
3:20 AM
@Shepmaster Yes
Isn't that necessary because next calls peek?
 
@SeanAllred ... lexical scoping will probably play a role at some point, but I'm not sure I'd throw it out there yet
 
or, sorry… "because next modifies self.current?"
 
Yes, it's necessary that next modifies something in order to advance. The non-obvious thing is that the compiler doesn't make a fine-grained decision like "only current will be modified"
it just says that "anything in self is fair game"
 
@SeanAllred In terms of fixing your issue - I would have tokenize pass in whatever it is you're iterating over to tokenize.
then you can iterate over that freely and mutate self.
so: fn tokenize(&mut self, input: Vec<Something>) { for tok in input { self.tokens.push(tok); } } ... etc.
or, more idiomatically I guess, input: &[Something] if you don't need the vector moved in
 
Or create objects that mirror the lifetimes
And you should probably check out doc.rust-lang.org/std/iter/trait.Iterator.html
cause it looks like you are creating an iterator (next) and implementing collect and filter
and peekable
bedtime!
 
3:43 AM
ciao!
 
@SimonWhitehead I'm tokenizing a string… Oh! Sorry! I forgot to add a piece of state to my struct that would've made this easier to understand. Reader should have a current_string: &str and tokenize should set that state where peek should use that state.
So the Vec<&str> will basically segment the input &str in memory
 
Unfortunately I'm not so well versed with Rust yet that I can just think of scenarios to help you :(
(unlike C#!)
if you have a sample gist that is closer to your current code I could take a look if you want.
 
 
8 hours later…
12:00 PM
@SeanAllred This might spoil the fun, but there are many blog articles out there about writing tokenizers in Rust. nitschinger.at/Text-Analysis-in-Rust-Tokenization
 
 
3 hours later…
3:23 PM
morning all
 
'Morning.
 
 
2 hours later…
5:35 PM
Ah, for once I'm glad I made an amateur mistake.
 
@E_net4 do tell
 
@Shepmaster I cast a pointer to &[&str] directly into a *const *const c_char.
 
@E_net4 do tell
 
@Shepmaster I was casting a &[&str].as_ptr() directly to a *const *const c_char.
Naturally, UB ensued.
...
Something strange happened here.
It might have to do with StackExchange server maintenance.
 
@Shepmaster Relevant to what?
I actually recall seeing that post, but I didn't look deep into it.
 
7:21 PM
@E_net4 I felt like you were trying to do static / double dispatch like stuff
and that felt similar
 
7:48 PM
@SimonWhitehead do you follow with ooooollllllll?
 
 
2 hours later…
9:26 PM
@Shepmaster In a way, yeah... But then again, I've yet to have a good look at that.
 
9:42 PM
Hello @EsamMohamed!
 
Is there a way to ignore/allow
error: named argument never used
  --> src\ops.rs:30:41
   |
30 |         println!($fmt, $($arg)*, blue = C::Blue, cyan = C::Cyan, green = C::Green, magenta = C::Magenta, red = C::Red, yellow = C::Yellow, reset = CReset);
   |
 
so your format string doesn't use green all the time?
 
Sounds like a Real Question
Wonder if there's a place to ask those
 
bingo!
<3
 

« first day (833 days earlier)      last day (2638 days later) »