#bitfighter IRC Log

Index Search ←Prev date Next date→

IRC Log for 2015-06-05

Timestamps are in GMT/BST.

00:35:55Watusimoto Quit (Ping timeout: 258 seconds)
01:01:56Nothing_Much Quit (Quit: Leaving)
01:32:49Nothing_Much has joined
02:12:13LordDVG has joined
02:16:21LordDVG Quit (Remote host closed the connection)
03:00:45Watusimoto has joined
04:04:42Nothing_Much Quit (Remote host closed the connection)
06:20:46koda has joined
09:10:39Darrel Quit (Read error: Connection reset by peer)
10:15:03Watusimoto Quit (Ping timeout: 265 seconds)
11:36:41Darrel has joined
11:55:57Darrel Quit (Ping timeout: 258 seconds)
11:56:17Darrel has joined
12:12:50Nothing_Much has joined
13:36:36watusimoto has joined
13:36:36ChanServ sets mode +o
14:43:19fordcars has joined
14:43:34fordcars Quit (Client Quit)
14:43:48fordcars has joined
14:46:28koda Quit (Ping timeout: 264 seconds)
14:56:47Nothing_Much Quit (Remote host closed the connection)
15:41:14fordcarsHey watusimoto, if you have time
15:41:25fordcarsconst char *name = "Blalalalalblla"
15:41:27fordcarsfoo(std::string(name));
15:41:44fordcarsTransforms name into an std::string for the function foo(), right?
15:42:17fordcarsCompiles fine, just wondering
16:19:16Skybax has joined
16:19:41SkybaxHello peoples
16:20:15SkybaxWhat's up fordy fordcars
16:20:23fordcarsHey Skyabxy
16:20:39fordcarsNothing much
16:22:00SkybaxNo he's not here
16:23:48fordcarsLol
16:27:29SkybaxAny progress on the laser tag??
16:40:20Skybax Quit (Ping timeout: 265 seconds)
17:20:40Lamp89 has joined
17:20:48Lamp89hai
17:29:04fordcarsSkybax, haven't worked on it since haha
17:29:25fordcarsOh yes I have
18:02:10Lamp89Today is my birthday
18:02:50Lamp89:E
18:04:24fordcarsHappy bday Lamp89!
18:04:34Lamp89thanx
18:21:26Lamp89 Quit ()
18:33:23watusimotohi fordcars
18:33:44watusimotoyes, it will work
18:33:49watusimotobut there are easier ways
18:33:58watusimotofoo(name) will also work
18:34:07watusimotoit will implicitly convert it during the function call
18:34:24watusimotobut even better just to use strings all the time, and avoid const char *
18:34:37watusimoto(we don't do that in BF, but we should!)
19:11:43fordcarsYou should?
19:11:46fordcarsOk, thanks!
19:16:09fordcars Quit (Ping timeout: 246 seconds)
19:40:41empyrean Quit (Remote host closed the connection)
19:42:24Darrel is now known as Darrel[HOME]
20:04:14Watusimoto_ has joined
20:09:07Skybax has joined
20:28:23fordcars has joined
20:34:41Skybax Quit (Ping timeout: 272 seconds)
20:38:16watusimotofordcars: use string when you can
20:38:34watusimotoit might be a tad less efficient, but only a tad, and it's much harder to hang yourself with it
20:38:46fordcarsstd::strings are fun
20:38:55watusimotowhen you pass a string to a function, make the function sig look like this:
20:39:03watusimotofun(const string &param)
20:39:05watusimotonot
20:39:10watusimotofun(string param)
20:39:14fordcarsWhy?
20:39:20watusimotothat will make passing much more efficient
20:39:34fordcarsOk, I'll try that out
20:39:41watusimotoin the first, you are essentially passing a pointer (a reference, actually), which is 4 bytes on a 32 bit system
20:40:02watusimotoin 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:16watusimotoif your function doesn't modify the string, the first is much better
20:40:19fordcarsWhat's the difference between a reference and a pointer?
20:40:36watusimotolots of subtle things
20:40:42watusimotothe concepts are generally the same
20:40:46watusimotoa reference cannot be null
20:40:54watusimotoa reference will clean itself up
20:41:08watusimotostring xxx; // will be automatically deleted when it goes out of scope
20:41:27watusimotostring *xxx = new string();// will leak memory if you don't clean it up
20:41:40watusimotodo the first, unless you have a specific reason not to
20:41:49fordcarsYes, so I've heard
20:41:54fordcarsI also heard of unique_ptr
20:42:15fordcarsA pointer that calls the deconstructor of the class when the scope ends
20:42:20watusimotonot sure about that... sounds like a boost pointer thing
20:42:26fordcarsIt's in std now
20:42:26Watusimoto_ Quit (Ping timeout: 255 seconds)
20:42:30watusimotowe use some of those in bf, but not unique_ptr
20:42:33watusimotoah, I see
20:42:41watusimotowe use shared_ptr sometiems
20:42:46watusimotothat also cleans itself up
20:42:48fordcarsYeah, tried it once, pretty much a way to not forget to clean memory
20:42:59fordcarsAh ok
20:43:03watusimotobut a reference is even better, unless you can't use one for some specific reason
20:43:21watusimoto(like you need to be able to have a value of NULL)
20:43:43fordcarsint number = 5; is a reference?
20:43:58watusimotono, that's just a POD variable (Plain Old Data)
20:44:04watusimotoit's just a simple variable
20:44:09fordcarsOr CoolClass var = new CoolClass(); ?
20:44:17watusimotothat won't compile
20:44:24fordcarsOh, uh no ()
20:44:29watusimotoCoolClass *var = new CVoolClass();
20:44:31watusimotoor better
20:44:38watusimotoCoolClass var;
20:44:53watusimotobecause the second is a reference, and the first is a pointer
20:44:55watusimotowhich leaks
20:45:00fordcarsAnd CoolClass var(params); works right?
20:45:09watusimotobasically don't use new unless you really have to
20:45:25watusimotoand if you have to, wrap it in a unique_ptr or some other smart pointer class
20:45:34watusimotoyes, that will work
20:46:02fordcarsOk nice
20:46:14watusimotowhen 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:25watusimotothat helps me check that I really did it when I come back later
20:46:41watusimotoit also reminds me to cleanup
20:46:54watusimotoand it adds to the friction, so I'm less likely to use new in the first place
20:46:59fordcarsRight
20:47:04watusimotoit makes me think "do I really need this?"
20:47:11watusimotosometimes you do... but usually not
20:47:33fordcarsAnd if you have a class, and have a member of that class to hold an instance of another class
20:47:43fordcarsYou use a reference too?
20:47:47watusimotosur
20:47:48watusimotosure
20:47:56fordcarsNice
20:48:01watusimotoclass xxx {
20:48:08watusimotootherclass yyy;
20:48:09watusimoto}
20:48:18watusimotoworks just fine
20:48:42watusimotowhen an instance of xxx is created, an otherclass is also created
20:49:04watusimotoand when your instance goes out of scope, the otherclass will get cleaned up too
20:49:13Watusimoto_ has joined
20:49:40fordcarsWhoa
20:49:45fordcarsWait
20:49:52fordcarsYou can write
20:49:55fordcarsclass xxx{
20:50:09fordcarsotherclass yyy("Hi");
20:50:10fordcars}
20:50:17fordcarsAnd it'll work? or nah
20:50:17watusimotosure
20:50:35watusimotowhen you do:
20:50:40fordcarsWow, so the constructor can be empty
20:50:41watusimotoxxx abc;
20:51:18watusimotoyou can then access abc.yyy.whatever_methods_are_here
20:51:32watusimotoyou get a "default" constructor
20:51:44watusimotothat does nothing
20:52:46fordcarsUh
20:53:04fordcarsOh
20:53:09fordcarsOk
20:53:26fordcarsSo, you don't need to write a constructor?
20:53:29fordcarswith xxx abc;
20:58:02watusimotohttps://ideone.com/IlM23i
20:58:23watusimotono
20:58:31watusimotothat's working code, btw
20:59:10watusimotoclick edit, then the green button
20:59:32fordcarsOhh nicey
20:59:52fordcarsUh, would you call that lazy initialization?
20:59:56fordcarsJust throwing that out there
21:00:02watusimotono
21:00:11watusimotothat's something very different
21:00:16fordcarsHah ok
21:01:26fordcarsSo inner is created automatically, even if there isn't one constructor. That's cool
21:01:45fordcarsBut what if you wanted to give arguments to outer,
21:02:15fordcarsyou would need to redefine inner?
21:02:37watusimotothat lazy init --> https://ideone.com/IlM23i
21:02:48watusimotono
21:02:48fordcarsSorry wait
21:03:16fordcarsSay you need the creator of Outer to give an argument to Inner
21:04:04watusimotoNow outer has a constructor
21:04:05watusimotohttps://ideone.com/IlM23i
21:05:52watusimotoone way to do that:
21:05:52watusimotohttps://ideone.com/IlM23i
21:06:02watusimoto(no longer lazy inits)
21:08:33fordcarsWhoa, what does that : do?
21:08:43fordcarsSorry for asking so many questions
21:10:53watusimotoyou create an OUter with the param 777
21:11:09watusimotothat calls the constructor, passing 777 as x
21:11:29watusimotothe constructor, before it runs, passes 777 to the constructor for inner
21:11:33watusimotoinner'
21:11:48watusimotos constructor runs, and stores 777 in value param
21:12:09watusimotothen when you call outer.inner.printme(), you see that the value 777 has been stored in outer's copy of inner
21:12:45empyrean has joined
21:12:57watusimotohttp://www.cprogramming.com/tutorial/initialization-lists-c++.html
21:13:50fordcarsAnd you can't do Outer(int x) : inner = 5 { }, say inner was an int?
21:16:08watusimotoyou would write that as
21:16:18watusimotoOuter(int x) : inner(5)
21:16:33watusimotobut you really gain nohting by initializing a POD variable in an initializer
21:16:51watusimotosome people like to do it; I don't. I think it is ugly
21:17:24fordcarsApparently it's useful for const
21:17:43watusimotoIn that article," Initialization Lists and Primitive Types" discusses that question a bit
21:17:57fordcarsYeah I am checking that out right now
21:18:01fordcarsTaking notes :P
21:18:14watusimotosoon it will be second nature
21:18:23watusimotoand may eventually (almost) make sense
21:18:33watusimotoc++ is a weird language
21:18:35fordcarsI hope so!
21:18:43fordcarsIt's tougher than javascript
21:18:54watusimotoin some ways
21:19:04fordcarsJavascript is nuts
21:19:05watusimotoin some ways easier
21:20:39fordcarsI don't get javascript in some ways
21:20:39fordcarsfor(_='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:48fordcarsThat code is perfectly valid
21:20:51watusimotoLooks good!
21:20:54fordcarsAnd without resources, makes this:
21:21:01fordcarshttp://js1k.com/2014-dragons/demo/1854
21:21:30fordcarsThis is pretty much magic
21:21:34watusimotoyup
21:21:56fordcarsOh wait it has textures I think
21:22:34fordcarsI didn't write that btw :P
21:23:20fordcarsOh, and one last question (maybe)
21:23:34fordcarsUh, do I need include guards?
21:23:45fordcarsI have a small cmake project here
21:23:50fordcarsAnd haven't used include guards
21:27:00watusimotowhat are guards?
21:27:06watusimotoI'm not really a cmake guy
21:27:15watusimotoI'm probably at about your level... maybe less
21:27:15fordcarsUh
21:27:21fordcarsI mean in c++
21:27:30fordcarsBut I thought there was a link with cmake
21:27:39watusimotook... what are guards in c++?
21:27:44fordcarsUh,
21:28:04fordcarsIf you don't know, I probably don't need them :P but here
21:28:15fordcarshttp://en.wikipedia.org/wiki/Include_guard
21:28:33fordcarsSay I have a class in a .h that takes std::strings in some methods
21:28:35watusimotoyes, you need them
21:28:38fordcarsI need to have #include <string>
21:29:05watusimotoyou can include <string> more than once... it will have guards inside it
21:29:11fordcarsOh
21:29:21watusimotothe fact you need them at all is a flaw in the language
21:29:22fordcarsThat makes it a bit more complicated now though
21:29:56watusimotowhy?
21:30:36fordcarsOh well, since it only affects .h individually, it's not that bad
21:30:47fordcarsI thought you need some stuff from where it was included
21:31:08watusimotono
21:31:24watusimotolook over that wiki article again
21:31:53watusimotothey save you from worrying about including the same file more than once
21:32:04fordcarsDoes Bitfighter use them>?
21:32:05watusimotoa problem that, I think, the compiler should handle for you, but doesn't
21:32:10watusimotoyes
21:32:13watusimotoin every .h file
21:32:14fordcarsNever say one of them
21:32:19fordcarsWow, I have a bad eye
21:32:24watusimotoyou never looked :-)
21:32:52fordcarsOh you're right
21:33:32fordcarsOk, so they are around the whole file
21:33:38watusimotoyes
21:33:44watusimotothey're kind of a pain
21:34:53fordcarsIf you look at that WIkipedia page: if father.h used somethings defined in grandfather.h, like foo, it would work?
21:35:05fordcarsWelp I guess it would
21:42:02watusimotoyes -- that's why father includes it
21:42:23fordcarsRight
21:42:31watusimotoincluding is really the same as making a copy and inserting it where your #include is
21:42:41watusimotoan exact byte-for-byte copy
21:42:49watusimotoit's exactly what the compiler does
21:42:54watusimotothen it interprets the result
21:43:17watusimotoinclude something twice with no guards, you'll get the same thing twice
21:43:36watusimotoinclude it twice with guards, you'll only get the first copy -- the second will be discarded
21:44:05fordcarsOh man, that actually makes sense
21:44:07watusimotoif you're unclear why, try it in a text editor and see what the results look like
21:44:26watusimotothe guards let you not worry about including it more than once by accident
21:44:52fordcarsSo, technically, you should only include each .h files once?
21:45:37watusimotoyes
21:45:47watusimotounless you want two copies of whatever is in there
21:45:51watusimotowhich you don't
21:45:59watusimotobut you don't need to worry about it
21:46:04watusimotobecause everyone adds guards
21:46:14watusimotobecause it would be a huge pain if you didn't
21:46:59fordcarsNice
21:47:15fordcarsThanks for answering my questions, it really helped
21:50:19watusimotoyou're welcome
21:56:01amgine123 has joined
21:56:14amgine123hello wattsimo anything new to test ?
21:56:21amgine123any new half way builds ?
22:00:26watusimotono nothing right now...
22:00:29watusimotoI have to run!
22:00:53watusimoto has left #bitfighter
23:07:19fordcars Quit (Quit: Page closed)
23:09:36amgine123 Quit (Ping timeout: 246 seconds)
23:17:49amgine123 has joined
23:58:45amgine123 Quit (Quit: Page closed)

Index Search ←Prev date Next date→

These logs were automatically created by BFLogBot on irc.freenode.net.