Timestamps are in GMT/BST.
| 00:35:55 | | Watusimoto Quit (Ping timeout: 258 seconds) |
| 01:01:56 | | Nothing_Much Quit (Quit: Leaving) |
| 01:32:49 | | Nothing_Much has joined |
| 02:12:13 | | LordDVG has joined |
| 02:16:21 | | LordDVG Quit (Remote host closed the connection) |
| 03:00:45 | | Watusimoto has joined |
| 04:04:42 | | Nothing_Much Quit (Remote host closed the connection) |
| 06:20:46 | | koda has joined |
| 09:10:39 | | Darrel Quit (Read error: Connection reset by peer) |
| 10:15:03 | | Watusimoto Quit (Ping timeout: 265 seconds) |
| 11:36:41 | | Darrel has joined |
| 11:55:57 | | Darrel Quit (Ping timeout: 258 seconds) |
| 11:56:17 | | Darrel has joined |
| 12:12:50 | | Nothing_Much has joined |
| 13:36:36 | | watusimoto has joined |
| 13:36:36 | | ChanServ sets mode +o |
| 14:43:19 | | fordcars has joined |
| 14:43:34 | | fordcars Quit (Client Quit) |
| 14:43:48 | | fordcars has joined |
| 14:46:28 | | koda Quit (Ping timeout: 264 seconds) |
| 14:56:47 | | Nothing_Much Quit (Remote host closed the connection) |
| 15:41:14 | fordcars | Hey watusimoto, if you have time |
| 15:41:25 | fordcars | const char *name = "Blalalalalblla" |
| 15:41:27 | fordcars | foo(std::string(name)); |
| 15:41:44 | fordcars | Transforms name into an std::string for the function foo(), right? |
| 15:42:17 | fordcars | Compiles fine, just wondering |
| 16:19:16 | | Skybax has joined |
| 16:19:41 | Skybax | Hello peoples |
| 16:20:15 | Skybax | What's up fordy fordcars |
| 16:20:23 | fordcars | Hey Skyabxy |
| 16:20:39 | fordcars | Nothing much |
| 16:22:00 | Skybax | No he's not here |
| 16:23:48 | fordcars | Lol |
| 16:27:29 | Skybax | Any progress on the laser tag?? |
| 16:40:20 | | Skybax Quit (Ping timeout: 265 seconds) |
| 17:20:40 | | Lamp89 has joined |
| 17:20:48 | Lamp89 | hai |
| 17:29:04 | fordcars | Skybax, haven't worked on it since haha |
| 17:29:25 | fordcars | Oh yes I have |
| 18:02:10 | Lamp89 | Today is my birthday |
| 18:02:50 | Lamp89 | :E |
| 18:04:24 | fordcars | Happy bday Lamp89! |
| 18:04:34 | Lamp89 | thanx |
| 18:21:26 | | Lamp89 Quit () |
| 18:33:23 | watusimoto | hi fordcars |
| 18:33:44 | watusimoto | yes, it will work |
| 18:33:49 | watusimoto | but there are easier ways |
| 18:33:58 | watusimoto | foo(name) will also work |
| 18:34:07 | watusimoto | it will implicitly convert it during the function call |
| 18:34:24 | watusimoto | but even better just to use strings all the time, and avoid const char * |
| 18:34:37 | watusimoto | (we don't do that in BF, but we should!) |
| 19:11:43 | fordcars | You should? |
| 19:11:46 | fordcars | Ok, thanks! |
| 19:16:09 | | fordcars Quit (Ping timeout: 246 seconds) |
| 19:40:41 | | empyrean Quit (Remote host closed the connection) |
| 19:42:24 | | Darrel is now known as Darrel[HOME] |
| 20:04:14 | | Watusimoto_ has joined |
| 20:09:07 | | Skybax has joined |
| 20:28:23 | | fordcars has joined |
| 20:34:41 | | Skybax Quit (Ping timeout: 272 seconds) |
| 20:38:16 | watusimoto | fordcars: use string when you can |
| 20:38:34 | watusimoto | it might be a tad less efficient, but only a tad, and it's much harder to hang yourself with it |
| 20:38:46 | fordcars | std::strings are fun |
| 20:38:55 | watusimoto | when you pass a string to a function, make the function sig look like this: |
| 20:39:03 | watusimoto | fun(const string ¶m) |
| 20:39:05 | watusimoto | not |
| 20:39:10 | watusimoto | fun(string param) |
| 20:39:14 | fordcars | Why? |
| 20:39:20 | watusimoto | that will make passing much more efficient |
| 20:39:34 | fordcars | Ok, I'll try that out |
| 20:39:41 | watusimoto | in the first, you are essentially passing a pointer (a reference, actually), which is 4 bytes on a 32 bit system |
| 20:40:02 | watusimoto | in the second, you are duplicating the string in memory, which for small strings isn't too bad, but for big ones is slow |
| 20:40:16 | watusimoto | if your function doesn't modify the string, the first is much better |
| 20:40:19 | fordcars | What's the difference between a reference and a pointer? |
| 20:40:36 | watusimoto | lots of subtle things |
| 20:40:42 | watusimoto | the concepts are generally the same |
| 20:40:46 | watusimoto | a reference cannot be null |
| 20:40:54 | watusimoto | a reference will clean itself up |
| 20:41:08 | watusimoto | string xxx; // will be automatically deleted when it goes out of scope |
| 20:41:27 | watusimoto | string *xxx = new string();// will leak memory if you don't clean it up |
| 20:41:40 | watusimoto | do the first, unless you have a specific reason not to |
| 20:41:49 | fordcars | Yes, so I've heard |
| 20:41:54 | fordcars | I also heard of unique_ptr |
| 20:42:15 | fordcars | A pointer that calls the deconstructor of the class when the scope ends |
| 20:42:20 | watusimoto | not sure about that... sounds like a boost pointer thing |
| 20:42:26 | fordcars | It's in std now |
| 20:42:26 | | Watusimoto_ Quit (Ping timeout: 255 seconds) |
| 20:42:30 | watusimoto | we use some of those in bf, but not unique_ptr |
| 20:42:33 | watusimoto | ah, I see |
| 20:42:41 | watusimoto | we use shared_ptr sometiems |
| 20:42:46 | watusimoto | that also cleans itself up |
| 20:42:48 | fordcars | Yeah, tried it once, pretty much a way to not forget to clean memory |
| 20:42:59 | fordcars | Ah ok |
| 20:43:03 | watusimoto | but a reference is even better, unless you can't use one for some specific reason |
| 20:43:21 | watusimoto | (like you need to be able to have a value of NULL) |
| 20:43:43 | fordcars | int number = 5; is a reference? |
| 20:43:58 | watusimoto | no, that's just a POD variable (Plain Old Data) |
| 20:44:04 | watusimoto | it's just a simple variable |
| 20:44:09 | fordcars | Or CoolClass var = new CoolClass(); ? |
| 20:44:17 | watusimoto | that won't compile |
| 20:44:24 | fordcars | Oh, uh no () |
| 20:44:29 | watusimoto | CoolClass *var = new CVoolClass(); |
| 20:44:31 | watusimoto | or better |
| 20:44:38 | watusimoto | CoolClass var; |
| 20:44:53 | watusimoto | because the second is a reference, and the first is a pointer |
| 20:44:55 | watusimoto | which leaks |
| 20:45:00 | fordcars | And CoolClass var(params); works right? |
| 20:45:09 | watusimoto | basically don't use new unless you really have to |
| 20:45:25 | watusimoto | and if you have to, wrap it in a unique_ptr or some other smart pointer class |
| 20:45:34 | watusimoto | yes, that will work |
| 20:46:02 | fordcars | Ok nice |
| 20:46:14 | watusimoto | when I write code, if I need to use "new", I always add a comment about where and when it will be cleaned up |
| 20:46:25 | watusimoto | that helps me check that I really did it when I come back later |
| 20:46:41 | watusimoto | it also reminds me to cleanup |
| 20:46:54 | watusimoto | and it adds to the friction, so I'm less likely to use new in the first place |
| 20:46:59 | fordcars | Right |
| 20:47:04 | watusimoto | it makes me think "do I really need this?" |
| 20:47:11 | watusimoto | sometimes you do... but usually not |
| 20:47:33 | fordcars | And if you have a class, and have a member of that class to hold an instance of another class |
| 20:47:43 | fordcars | You use a reference too? |
| 20:47:47 | watusimoto | sur |
| 20:47:48 | watusimoto | sure |
| 20:47:56 | fordcars | Nice |
| 20:48:01 | watusimoto | class xxx { |
| 20:48:08 | watusimoto | otherclass yyy; |
| 20:48:09 | watusimoto | } |
| 20:48:18 | watusimoto | works just fine |
| 20:48:42 | watusimoto | when an instance of xxx is created, an otherclass is also created |
| 20:49:04 | watusimoto | and when your instance goes out of scope, the otherclass will get cleaned up too |
| 20:49:13 | | Watusimoto_ has joined |
| 20:49:40 | fordcars | Whoa |
| 20:49:45 | fordcars | Wait |
| 20:49:52 | fordcars | You can write |
| 20:49:55 | fordcars | class xxx{ |
| 20:50:09 | fordcars | otherclass yyy("Hi"); |
| 20:50:10 | fordcars | } |
| 20:50:17 | fordcars | And it'll work? or nah |
| 20:50:17 | watusimoto | sure |
| 20:50:35 | watusimoto | when you do: |
| 20:50:40 | fordcars | Wow, so the constructor can be empty |
| 20:50:41 | watusimoto | xxx abc; |
| 20:51:18 | watusimoto | you can then access abc.yyy.whatever_methods_are_here |
| 20:51:32 | watusimoto | you get a "default" constructor |
| 20:51:44 | watusimoto | that does nothing |
| 20:52:46 | fordcars | Uh |
| 20:53:04 | fordcars | Oh |
| 20:53:09 | fordcars | Ok |
| 20:53:26 | fordcars | So, you don't need to write a constructor? |
| 20:53:29 | fordcars | with xxx abc; |
| 20:58:02 | watusimoto | https://ideone.com/IlM23i |
| 20:58:23 | watusimoto | no |
| 20:58:31 | watusimoto | that's working code, btw |
| 20:59:10 | watusimoto | click edit, then the green button |
| 20:59:32 | fordcars | Ohh nicey |
| 20:59:52 | fordcars | Uh, would you call that lazy initialization? |
| 20:59:56 | fordcars | Just throwing that out there |
| 21:00:02 | watusimoto | no |
| 21:00:11 | watusimoto | that's something very different |
| 21:00:16 | fordcars | Hah ok |
| 21:01:26 | fordcars | So inner is created automatically, even if there isn't one constructor. That's cool |
| 21:01:45 | fordcars | But what if you wanted to give arguments to outer, |
| 21:02:15 | fordcars | you would need to redefine inner? |
| 21:02:37 | watusimoto | that lazy init --> https://ideone.com/IlM23i |
| 21:02:48 | watusimoto | no |
| 21:02:48 | fordcars | Sorry wait |
| 21:03:16 | fordcars | Say you need the creator of Outer to give an argument to Inner |
| 21:04:04 | watusimoto | Now outer has a constructor |
| 21:04:05 | watusimoto | https://ideone.com/IlM23i |
| 21:05:52 | watusimoto | one way to do that: |
| 21:05:52 | watusimoto | https://ideone.com/IlM23i |
| 21:06:02 | watusimoto | (no longer lazy inits) |
| 21:08:33 | fordcars | Whoa, what does that : do? |
| 21:08:43 | fordcars | Sorry for asking so many questions |
| 21:10:53 | watusimoto | you create an OUter with the param 777 |
| 21:11:09 | watusimoto | that calls the constructor, passing 777 as x |
| 21:11:29 | watusimoto | the constructor, before it runs, passes 777 to the constructor for inner |
| 21:11:33 | watusimoto | inner' |
| 21:11:48 | watusimoto | s constructor runs, and stores 777 in value param |
| 21:12:09 | watusimoto | then when you call outer.inner.printme(), you see that the value 777 has been stored in outer's copy of inner |
| 21:12:45 | | empyrean has joined |
| 21:12:57 | watusimoto | http://www.cprogramming.com/tutorial/initialization-lists-c++.html |
| 21:13:50 | fordcars | And you can't do Outer(int x) : inner = 5 { }, say inner was an int? |
| 21:16:08 | watusimoto | you would write that as |
| 21:16:18 | watusimoto | Outer(int x) : inner(5) |
| 21:16:33 | watusimoto | but you really gain nohting by initializing a POD variable in an initializer |
| 21:16:51 | watusimoto | some people like to do it; I don't. I think it is ugly |
| 21:17:24 | fordcars | Apparently it's useful for const |
| 21:17:43 | watusimoto | In that article," Initialization Lists and Primitive Types" discusses that question a bit |
| 21:17:57 | fordcars | Yeah I am checking that out right now |
| 21:18:01 | fordcars | Taking notes :P |
| 21:18:14 | watusimoto | soon it will be second nature |
| 21:18:23 | watusimoto | and may eventually (almost) make sense |
| 21:18:33 | watusimoto | c++ is a weird language |
| 21:18:35 | fordcars | I hope so! |
| 21:18:43 | fordcars | It's tougher than javascript |
| 21:18:54 | watusimoto | in some ways |
| 21:19:04 | fordcars | Javascript is nuts |
| 21:19:05 | watusimoto | in some ways easier |
| 21:20:39 | fordcars | I don't get javascript in some ways |
| 21:20:39 | fordcars | for(_='atZMZh.YYsin(X*Xe/8W++)V>s;sVUfor(TUToSXo)R255Q256P&QOO*PN16L=0;KKL>J)+&&),]=>><<10|a+p+4210943TsK],=[L*p[9858122,1-,63+Rfunction([d]ImageDZa(var =-1;2> )*n+(e()*(n);TdK3>d;dVp;e[l++=e,t,n){returnYrandom()1023 |
| 21:20:48 | fordcars | That code is perfectly valid |
| 21:20:51 | watusimoto | Looks good! |
| 21:20:54 | fordcars | And without resources, makes this: |
| 21:21:01 | fordcars | http://js1k.com/2014-dragons/demo/1854 |
| 21:21:30 | fordcars | This is pretty much magic |
| 21:21:34 | watusimoto | yup |
| 21:21:56 | fordcars | Oh wait it has textures I think |
| 21:22:34 | fordcars | I didn't write that btw :P |
| 21:23:20 | fordcars | Oh, and one last question (maybe) |
| 21:23:34 | fordcars | Uh, do I need include guards? |
| 21:23:45 | fordcars | I have a small cmake project here |
| 21:23:50 | fordcars | And haven't used include guards |
| 21:27:00 | watusimoto | what are guards? |
| 21:27:06 | watusimoto | I'm not really a cmake guy |
| 21:27:15 | watusimoto | I'm probably at about your level... maybe less |
| 21:27:15 | fordcars | Uh |
| 21:27:21 | fordcars | I mean in c++ |
| 21:27:30 | fordcars | But I thought there was a link with cmake |
| 21:27:39 | watusimoto | ok... what are guards in c++? |
| 21:27:44 | fordcars | Uh, |
| 21:28:04 | fordcars | If you don't know, I probably don't need them :P but here |
| 21:28:15 | fordcars | http://en.wikipedia.org/wiki/Include_guard |
| 21:28:33 | fordcars | Say I have a class in a .h that takes std::strings in some methods |
| 21:28:35 | watusimoto | yes, you need them |
| 21:28:38 | fordcars | I need to have #include <string> |
| 21:29:05 | watusimoto | you can include <string> more than once... it will have guards inside it |
| 21:29:11 | fordcars | Oh |
| 21:29:21 | watusimoto | the fact you need them at all is a flaw in the language |
| 21:29:22 | fordcars | That makes it a bit more complicated now though |
| 21:29:56 | watusimoto | why? |
| 21:30:36 | fordcars | Oh well, since it only affects .h individually, it's not that bad |
| 21:30:47 | fordcars | I thought you need some stuff from where it was included |
| 21:31:08 | watusimoto | no |
| 21:31:24 | watusimoto | look over that wiki article again |
| 21:31:53 | watusimoto | they save you from worrying about including the same file more than once |
| 21:32:04 | fordcars | Does Bitfighter use them>? |
| 21:32:05 | watusimoto | a problem that, I think, the compiler should handle for you, but doesn't |
| 21:32:10 | watusimoto | yes |
| 21:32:13 | watusimoto | in every .h file |
| 21:32:14 | fordcars | Never say one of them |
| 21:32:19 | fordcars | Wow, I have a bad eye |
| 21:32:24 | watusimoto | you never looked :-) |
| 21:32:52 | fordcars | Oh you're right |
| 21:33:32 | fordcars | Ok, so they are around the whole file |
| 21:33:38 | watusimoto | yes |
| 21:33:44 | watusimoto | they're kind of a pain |
| 21:34:53 | fordcars | If you look at that WIkipedia page: if father.h used somethings defined in grandfather.h, like foo, it would work? |
| 21:35:05 | fordcars | Welp I guess it would |
| 21:42:02 | watusimoto | yes -- that's why father includes it |
| 21:42:23 | fordcars | Right |
| 21:42:31 | watusimoto | including is really the same as making a copy and inserting it where your #include is |
| 21:42:41 | watusimoto | an exact byte-for-byte copy |
| 21:42:49 | watusimoto | it's exactly what the compiler does |
| 21:42:54 | watusimoto | then it interprets the result |
| 21:43:17 | watusimoto | include something twice with no guards, you'll get the same thing twice |
| 21:43:36 | watusimoto | include it twice with guards, you'll only get the first copy -- the second will be discarded |
| 21:44:05 | fordcars | Oh man, that actually makes sense |
| 21:44:07 | watusimoto | if you're unclear why, try it in a text editor and see what the results look like |
| 21:44:26 | watusimoto | the guards let you not worry about including it more than once by accident |
| 21:44:52 | fordcars | So, technically, you should only include each .h files once? |
| 21:45:37 | watusimoto | yes |
| 21:45:47 | watusimoto | unless you want two copies of whatever is in there |
| 21:45:51 | watusimoto | which you don't |
| 21:45:59 | watusimoto | but you don't need to worry about it |
| 21:46:04 | watusimoto | because everyone adds guards |
| 21:46:14 | watusimoto | because it would be a huge pain if you didn't |
| 21:46:59 | fordcars | Nice |
| 21:47:15 | fordcars | Thanks for answering my questions, it really helped |
| 21:50:19 | watusimoto | you're welcome |
| 21:56:01 | | amgine123 has joined |
| 21:56:14 | amgine123 | hello wattsimo anything new to test ? |
| 21:56:21 | amgine123 | any new half way builds ? |
| 22:00:26 | watusimoto | no nothing right now... |
| 22:00:29 | watusimoto | I have to run! |
| 22:00:53 | | watusimoto has left #bitfighter |
| 23:07:19 | | fordcars Quit (Quit: Page closed) |
| 23:09:36 | | amgine123 Quit (Ping timeout: 246 seconds) |
| 23:17:49 | | amgine123 has joined |
| 23:58:45 | | amgine123 Quit (Quit: Page closed) |