code logs -> 2011 -> Mon, 10 Oct 2011< code.20111009.log - code.20111011.log >
--- Log opened Mon Oct 10 00:00:19 2011
00:24 McMartin_ is now known as McMartin
00:58 You're now known as TheWatcher[T-2]
01:06 You're now known as TheWatcher[zZzZ]
01:07 kw|GO_BREWERS is now known as kw|GO_PACKERS
01:08 gnolam [lenin@Nightstar-202a5047.priv.bahnhof.se] has quit [[NS] Quit: Z?]
01:26 Attilla [Some.Dude@Nightstar-f29f718d.cable.virginmedia.com] has quit [Ping timeout: 121 seconds]
01:30 celticminstrel is now known as celmin|supper
02:03 Stalker [Z@Nightstar-5aa18eaf.balk.dk] has quit [[NS] Quit: If the world didn't suck, we'd all fall off.]
02:19 celmin|supper is now known as celticminstrel
03:25 Stalker [Z@Nightstar-5aa18eaf.balk.dk] has joined #code
03:28 Reiver [orthianz@3CF3A5.E1CD01.C6689C.33956A] has quit [Ping timeout: 121 seconds]
03:29 Reiver [orthianz@3CF3A5.E1CD01.C6689C.33956A] has joined #code
03:42 Kindamoody[zZz] is now known as Kindamoody
03:54 Alek [omegaboot@Nightstar-10752b3e.il.comcast.net] has quit [[NS] Quit: ]
04:23 cpux|2 [cpux@Nightstar-c5874a39.dyn.optonline.net] has joined #code
04:26 cpux [cpux@Nightstar-c5874a39.dyn.optonline.net] has quit [Ping timeout: 121 seconds]
04:35 cpux [cpux@Nightstar-c5874a39.dyn.optonline.net] has joined #code
04:37 cpux|2 [cpux@Nightstar-c5874a39.dyn.optonline.net] has quit [Ping timeout: 121 seconds]
04:44 kw|GO_PACKERS is now known as kwsn
04:46 Stalker [Z@Nightstar-5aa18eaf.balk.dk] has quit [[NS] Quit: If the world didn't suck, we'd all fall off.]
05:09 Alek [omegaboot@Nightstar-10752b3e.il.comcast.net] has joined #code
05:19 Reiver [orthianz@3CF3A5.E1CD01.C6689C.33956A] has quit [[NS] Quit: Going dooooown...]
05:25 Stalker [Z@Nightstar-3602cf5a.cust.comxnet.dk] has joined #code
06:07 Vash [Vash@Nightstar-f03c5637.sd.cox.net] has joined #code
06:38 Derakon is now known as Derakon[AFK]
06:53 celticminstrel [celticminst@Nightstar-5d22ab1d.cable.rogers.com] has quit [[NS] Quit: And lo! The computer falls into a deep sleep, to awake again some other day!]
07:04
< McMartin>
Arghl
07:04
< McMartin>
I had forgotten the degree to which SpaceChem was The Good Stuff.
07:11 Stalker [Z@Nightstar-3602cf5a.cust.comxnet.dk] has quit [Ping timeout: 121 seconds]
07:21 Vash [Vash@Nightstar-f03c5637.sd.cox.net] has quit [[NS] Quit: I <3Lovecraft<3 Vorn!]
07:33
< Vornicus>
How The Good Stuff Is It?
08:03 Reiver [orthianz@3CF3A5.E1CD01.C6689C.33956A] has joined #code
08:22
< McMartin>
Sudden solutions in letters of fire good, requiring me to fire it up to try my solutions.
08:23
< McMartin>
Does not always work
08:24
< McMartin>
I have however made some epically horrible solutions that I'm pretty sure I can do better on.
08:25
< McMartin>
(I just got the flip-flop element, which allows for incredible perversions)
08:25
< McMartin>
(Which I mistyped originally as "perfections"~)
08:41 * Vornicus still hasn't figured out Like A Boss or that other one.
09:01
< McMartin>
I seem to be the only person who has gotten to chapter 7
09:30 gnolam [lenin@Nightstar-202a5047.priv.bahnhof.se] has joined #code
09:34 You're now known as TheWatcher
09:39 Attilla [Some.Dude@Nightstar-f29f718d.cable.virginmedia.com] has joined #code
10:03 AnnoDomini [annodomini@FFB3F3.4C5BE8.2014E2.DC0864] has joined #code
11:42
< AnnoDomini>
http://roflcopter.pl/5346
11:46 Kindamoody is now known as Kindamoody|noms
12:27 Kindamoody|noms is now known as Kindamoody
12:31 Stalker [Z@Nightstar-3602cf5a.cust.comxnet.dk] has joined #code
12:59 AnnoDomini [annodomini@FFB3F3.4C5BE8.2014E2.DC0864] has quit [[NS] Quit: Away!]
13:32 Kindamoody is now known as Kindamoody|out
13:51 AnnoDomini [annodomini@60F158.737D66.CA1918.CC7562] has joined #code
14:24 AnnoDomini [annodomini@60F158.737D66.CA1918.CC7562] has quit [[NS] Quit: I gotta go.]
16:21 celticminstrel [celticminst@Nightstar-5d22ab1d.cable.rogers.com] has joined #code
16:44 Stalker [Z@Nightstar-3602cf5a.cust.comxnet.dk] has quit [Ping timeout: 121 seconds]
16:46 Stalker [Z@Nightstar-3602cf5a.cust.comxnet.dk] has joined #code
18:13
< Phox>
So, riddle me this. I'm learning C++. One of our labs has us do some crap to find the length and angle from a baseline to a bunch of points. I've got to pass these around a bit as well. The solution I came up with was to use a struct, but that's not really leveraging object-oriented. So, is there a better way?
18:16
< Lingerance>
A struct is the same as a class, just the access level for properties defaults to something different (public vs protected)
18:16
< Lingerance>
You can attach methods to both.
18:17
< Lingerance>
For a C++ lab I'd use class + methods though, as some teachers will chew you out for doing it the "C way"
18:18
< Phox>
Well, that's just it. Three weeks in, and he's just introduced cin/cout. So, I was looking to find what I should research to do it the right way, 'cause I'm not going to learn it from this guy any time soon
18:18
< Lingerance>
Lovely
18:20
< Lingerance>
If you pastebin a simple thing I'll pastebin a class + methods version if you'd like
18:21 Kindamoody|out is now known as Kindamoody
18:24
< Phox>
I'll try working through a few tutorials first. I'll give you a shout when I've got a finished product, if you're still on.
18:25
< Lingerance>
Alirght
18:27 * ToxicFrog upreads
18:28
< Phox>
Ow, wow. Shift delete nukes the code, in this IDE. Gotta watch lazy fingers
18:28
<@ToxicFrog>
First instinct here: make it a class, give it methods for distance between two points (point.distanceTo(otherPoint)), vector angle difference, etc.
18:31
<@ToxicFrog>
Really, not that different from the C way; you just have 'class Point' instead of 'typedef struct {...} Point', and call 'p1.angle(p2)' rather than 'point_angle(p1, p2)'
18:36 Stalker [Z@Nightstar-3602cf5a.cust.comxnet.dk] has quit [[NS] Quit: If the world didn't suck, we'd all fall off.]
18:40
< celticminstrel>
I never really got the point of declaring your structs in a typedef statement.
18:42
< Lingerance>
It's a C thing
18:42
< Lingerance>
If you do: struct X { ... }; you have to do: struct X var; to make a variable with that struct.
18:42
< Lingerance>
Otherwise you do a typedef and it's just X var;
18:55
< Phox>
Pointers initialize to null, right?
18:55
<@ToxicFrog>
Pointers, like everything else in C/++, initialize to whatever was in memory at the time except in certain specific situations.
18:55
<@ToxicFrog>
So, no, initialize them to NULL manually.
18:56
< Phox>
Cool. I'll throw that in the constructor code
18:57
< Phox>
New things to learn. This is gonna be the pinnacle. All my code after this is gonna be downhill
19:07
< gnolam>
When you say "constructor code", that should mean "initialization list".
19:11
< Phox>
I suppose it is. I had only heard the term. I thought it was, like, a special-purpose method inside the class, but reading more into it, it's a bit less magical
19:13
< gnolam>
The constructor is a special method.
19:13
< gnolam>
However, plain initializations (like setting pointers to 0) should go in a special initialization list.
19:14
< gnolam>
As well as plain assignments.
19:15 Derakon [chriswei@Nightstar-f68d7eb4.ca.comcast.net] has joined #code
19:16
< gnolam>
E.g. instead of
19:16
< gnolam>
Foo::Foo(int bar, int baz)
19:16
< gnolam>
{
19:16
< gnolam>
this->bar = bar;
19:16
< gnolam>
this->baz = baz;
19:16
< gnolam>
this->frotz = 0;
19:16
< gnolam>
}
19:16
< gnolam>
You do
19:16
< gnolam>
Foo::Foo(int bar, int baz)
19:16
< gnolam>
: bar(bar), baz(baz), frotz(0)
19:16
< gnolam>
{
19:16
< gnolam>
}
19:16
< Derakon>
But you have to do them in order!
19:16
< Derakon>
Which I always found to be silly.
19:16
< Derakon>
(Assuming this is C++ we're talking about)
19:16
< gnolam>
Yes.
19:18
< Derakon>
So, question: I have an array of 12-bit values, represented as a char array.
19:18
< Derakon>
I want to upcast this to 16-bit values.
19:18
< Derakon>
What's the best way to handle this?
19:20
< gnolam>
How are the 12-bit values stored exactly?
19:20
< gnolam>
Just packed, in the char array?
19:21
< Derakon>
Yeah.
19:21
< Derakon>
It's 8398080 bytes for a 2592x2160 image.
19:31 Kindamoody is now known as Kindamoody[zZz]
19:32
< celticminstrel>
Lingerance: I understand that, but you can just declare the struct normally and then typedef it separately.
19:33 Vash [Vash@Nightstar-f03c5637.sd.cox.net] has joined #code
19:33
< Lingerance>
That's an extra line :p
19:33
< celticminstrel>
Phox: While what TF said is generally true, anything declared static is zero-initialized in C++.
19:33
< celticminstrel>
Lingerance: Yeah, but it makes more sense to me.
19:35
< celticminstrel>
Derakon: You don't have to do them in order, but it's a bad idea not to since they're initialized in declaration order, not order of appearance in the constructor.
19:36
< Phox>
Hmm. So, the idea of classes is to increase the control over the scope of variables, yeah? I've got two classes here. I find the value of a variable in one class' method, but I need that value in both this class' method, and a method in another class. Is that a sign that the two classes aren't as independent as I thought, and I should combine them?
19:36
< celticminstrel>
Depends...
19:37
< Phox>
I'll try and give give my example
19:37
< Phox>
I've got an arclength, and I need to put equally spaced points along it with a maximum spacing no more than a certain distance.
19:38
< Phox>
It's part of the earlier stuff I was talking about, finding angles and distance from a basepoint
19:39
< Phox>
So, I've got one class where I solve for all the angles I need, as well as the number of points I need.
19:39
< Phox>
My second class is just a struct, where I record the number of points, and have two arrays for length and angle
19:40
< Phox>
The problem is, I need the number of points in the first array to solve for the angles, and I need it in the second class for malloc to create the arrays
19:40
< Phox>
It's kind of stupid to have the same variable stored in two places, though
19:41
< celticminstrel>
What are the classes called?
19:41
< Phox>
cpoints and ctriangles
19:41
< Phox>
* ctriangle, rather
19:41
< celticminstrel>
ctriangles solves for the angles or...?
19:42
< Phox>
Yeah
19:42
< celticminstrel>
I guess you could make ctriangle have a cpoints...
19:42 Stalker [Z@Nightstar-5aa18eaf.balk.dk] has joined #code
19:42
< celticminstrel>
Or you could combine them. I dunno really.
19:43
< Phox>
Me neither. I'm bastardizing this, I think. I'll put up some code when it's done, and I'd appreciate it if someonecould tell me how I could make it better
19:44
< gnolam>
Derakon: In that case, I don't think there is a "clever" solution.
19:45
< Derakon>
Dang.
19:45
< celticminstrel>
I'm guessing you can't have an array of bitfields?
19:45
< celticminstrel>
That seems like a likely restriction, at least.
19:45
< Derakon>
The "receive an array of chars" bit is outside my influence.
19:46
< Derakon>
It's returned by a third-party library.
19:46
< celticminstrel>
Well sure.
19:47
< gnolam>
Phox: are you using malloc to mean "dynamic allocation in general", or the actual malloc()?
19:47
< Phox>
The actual malloc
19:47 * Lingerance would have three classes: Point (x,y(,z)), Line (line, angle, Point *a, *b) and PointMap (Point[], Line[]), give the PointMap an array of points, it uses those to make a bunch of Lines. (RE: request for possible solution)
19:48
< gnolam>
When in C++, use new.
19:48
< celticminstrel>
new blah[5], delete[] blah.
19:48
< gnolam>
malloc() just allocates memory. new allocates memory and calls constructors.
19:48
< celticminstrel>
Or new blah(stuff) and delete blah.
19:50
< Phox>
Lingerance: I wish I could do that, in this case. I'm given a chordlength, radius of a circle, and maximum arclength between points, so I don't know the location of any of the points beforehand.
19:50 * Phox looks up new
19:51
< gnolam>
new also returns values of the correct type. So you don't have to go around casting the (void *) that malloc returns.
19:51
< Lingerance>
Same model can be used, just have a different constructor.
19:51
< gnolam>
(And, of course, it's The C++ Way.)
19:52
< celticminstrel>
(If for some reason you just wanted the memory allocated, I think you can also call operator new as a function. But there're very few reasons you would want to do that.)
19:54
< celticminstrel>
As for arrays of bitfields, it doesn't look like the syntax even allows for it.
19:54
< celticminstrel>
(Which doesn't surprise me really; they'd probably be a nightmare for the compiler to deal with.)
19:55 Stalker [Z@Nightstar-5aa18eaf.balk.dk] has quit [Ping timeout: 121 seconds]
19:56
< celticminstrel>
(If they were possible, you'd be able to reinterpret_cast your array to an array of bitfields.)
20:09 Vash [Vash@Nightstar-f03c5637.sd.cox.net] has quit [[NS] Quit: I <3Lovecraft<3 Vorn!]
20:10
< Phox>
Oooh, wow, did I miss something very very basic? Within a class, do the methods have access to all the variables? Like, class foo { int bar, baz; void frotz(int, int) {bar=baz;} would update bar without me passing it by reference?
20:10
< Phox>
Or, is this page I'm reading really out of whack?
20:11
< Lingerance>
It's part of C++ scoping rules
20:11
< Phox>
variables act as globals within a class?
20:11
< Lingerance>
That's an incorrect way of phrasing it, but yes.
20:11
< Phox>
Wow
20:11
< Phox>
That simplifies so much of my code
20:13
< Phox>
So, could I call frotz without specifying my two integers, and it would still work?
20:13
< Phox>
Also, frotz? how did this convention get started?
20:18
< Derakon>
A given instance of a class has access to all variables declared as fields of that class.
20:18
< Derakon>
And "frotz" is a less-common name for "foo". :)
20:19
< Phox>
Well, this blew my mind. I had methods passing, like, six arguments around. It was driving me nuts, because I don't like that. It means my methods are too complex, but the alternative was one-line methods
20:55
< Derakon>
Does this look reasonable for converting from 12-bit to 16-bit? http://pastebin.com/T6hzqu6C
20:55
< Derakon>
outputBuffer is a short*; curBuffer->data is a char*.
20:55
< Derakon>
numElements is the number of pixels.
20:57 * Derakon removes a ">> 4" from line 6.
20:58
< Derakon>
Hm, this can be compacted.
20:59
< Derakon>
No wait, I'm a dumbass.
20:59
< Derakon>
It was right the first time, I think. Argh.
21:15
< celticminstrel>
The correct way to think about it, Phox, is that each class member function has an invisible parameter "this" which is a pointer to the object and through which you can access anything declared in the object.
21:16
< celticminstrel>
But for simplicity it lets you leave off the "this->" if you wish.
21:16
< Derakon>
Many object-oriented languages make the "this" explicit.
21:16
< Derakon>
For example, in Python, doing "foo.classFunc(arg1)" is exactly equivalent to doing "classFunc(foo, arg1)".
21:17
< Derakon>
(Where "foo" is an instance of a class, and classFunc is a function defined on that class)
21:21
< celticminstrel>
Python forces you to even include that in the function argument list, which keeps catching me off-guard.
21:21
< celticminstrel>
When declaring the function, I mean.
21:21
< Derakon>
Yeah.
21:22
< Derakon>
def classFunc(self, arg1)
21:22
< gnolam>
Derakon: you need to mask out the half bytes.
21:23
< gnolam>
Or wait
21:23
< gnolam>
Nevermind
21:24
< Derakon>
Gnolam: yeah, I should've &= with 0x0fff instead of 0xffff.
21:31
< Derakon>
Times like this I'm glad for that problem set I had in college where we had to write various more-or-less complicated functions without access to things like multiplication/division/more than one storage variable/etc.
21:32
< Derakon>
That was a big help in visualizing memory and understanding the bitshift operators.
21:33
< Phox>
Ever do low-level work on micros?
21:34
< Phox>
It's a lot of fun if you like working directly on bits. I had a course on the RISC architecture that used C and assembly. So much fun
21:37
< Phox>
It still makes me laugh when people say it's impossible to swap two values with only two storage variables.
21:37
< Phox>
I think there might even be a mnemonic in assembly for it, but you can get away with a couple XORs
21:47
< Derakon>
Dialog box: "You were disconnected from the Windows-based computer. Another user has connected to the Windows-based computer. Try reconnecting to the Windows-based computer."
21:48
< Phox>
XD
21:52
< Derakon>
So, random bit of work silliness for you all.
21:52
< Derakon>
We have a semi-clean room that our new microscope is being developed in.
21:52
< Derakon>
This includes some new devices (particularly a new camera) that I'm writing the control software for.
21:53
< Derakon>
However, I'm not allowed into the clean room without my coworker or my boss present, because my boss doesn't trust computers and by extension anyone who works on them.
21:53
< Derakon>
(Really, that's the best model I've come up with for explaining his behavior)
21:53
< Derakon>
So I don't have a key to the room.
21:53
< Phox>
You could be a haxxor, trying to steal all the microspoic secrets
21:53
< Derakon>
Problem: boss and coworker are both gone on vacation.
21:53
< Derakon>
Solution: I use remote login to access the computers.
21:53
< Derakon>
I don't really need to see the hardware I'm controlling to control it, theoretically anyway.
21:54
< Derakon>
New problem: the camera occasionally gets into a state that requires pushing the power button on the camera itself.
21:54
< Derakon>
Solution: uhh...
21:54
< Phox>
Pull the breaker
21:54
< Phox>
That'll reset it
21:54
< Derakon>
(Currently, solution is to walk across the entire building to get a room key from the guys we share that lab with, go down three floors to the clean room, put on the booties, walk in, push the button, walk out, take off the booties, go up three flights of stairs, return the key, and get back to work...)
21:55
< Derakon>
(But I can't tell my boss that or he'd have a conniption)
21:58
< celticminstrel>
How do I disambiguate between a git tag and a git branch of the same name?
21:58
< Phox>
Could you get a long poker, the just stand at the door and poke the button? Maybe even rig up a system where you don't even have to go in, just pull a string that pushes the poker?
22:02
< TheWatcher>
You need a Finglonger!
22:03
< Derakon>
Yeah, we could install a computer next to the camera and use its DVD drive bay to push the button.
22:04
< Phox>
Haha
22:04
< celticminstrel>
I need to delete a branch in the remote repository, but it has the same name as a tag.
22:08
< TheWatcher>
celticminstrel: git checkout tags/<name> will look at the tags, without tags/ it assumes you want a branch
22:08
< TheWatcher>
similar stuff with other commands
22:09
< TheWatcher>
wait, you want to delete. Hm.
22:09
< TheWatcher>
I think it should still work on the branch instead of the tag
22:09
< celticminstrel>
It says it's ambiguous.
22:09
< celticminstrel>
.
22:10
< celticminstrel>
Maybe I'll try git push origin :branches/<name>...
22:10
< celticminstrel>
Nope.
22:11
< celticminstrel>
Oh it says something about not beginning with refs.
22:11
< celticminstrel>
:refs/branches/<name> worked. :)
22:11
< celticminstrel>
Thanks for the hint.
22:13
< gnolam>
Derakon: .. wait, are those just char* and short* or are they in fact unsigned?
22:14
< gnolam>
Unexpected arithmetic right shifts can ruin anyone's day.
22:14
< Derakon>
They're in fact unsigned, so there should be no sign bit.
22:31 Derakon [chriswei@Nightstar-f68d7eb4.ca.comcast.net] has quit [[NS] Quit: leaving]
--- Log closed Tue Oct 11 00:00:36 2011
code logs -> 2011 -> Mon, 10 Oct 2011< code.20111009.log - code.20111011.log >

[ Latest log file ]