buffer.clear simply "resets" the buffer, and doesn't actually "clear" the buffer in the sense that data in the buffer is deleted. From what I read, it doesn't seem like it would affect normal coding too much, but then again, programmers like to do funny things.public final Buffer clear()
Clears this buffer. The position is set to zero, the limit is set to the capacity, and the mark is discarded.
Invoke this method before using a sequence of channel-read or put operations to fill this buffer. For example:
buf.clear(); // Prepare buffer for reading
in.read(buf); // Read data
This method does not actually erase the data in the buffer, but it is named as if it did because it will most often be used in situations in which that might as well be the case.
Programming, computers, etc. [Serious]
Re: Programming, computers, etc. [Serious]
Oh... Reading the context in the documentation makes it a little more clear.
If two wrongs don't make a right, try three. - Laurence J. Peter
- Anonymously Famous
- JKL; Assassin

- Posts: 11413
- Joined: Thu Mar 03, 2011 6:52 pm
- Location: Area ???, under Bermuda Triangle
Re: Programming, computers, etc. [Serious]
Sometimes resetting the buffer might be useful.
BOTTOM TEXT
Proud poster of the 300kth post in GeneralThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
- atomtengeralattjaro
- Site Admin

- Posts: 35622
- Joined: Wed May 23, 2007 3:43 pm
- Location: green
- Contact:
Re: Programming, computers, etc. [Serious]
meh. okay then.
today i continue fiddling around in java networking.
today i continue fiddling around in java networking.

- Anonymously Famous
- JKL; Assassin

- Posts: 11413
- Joined: Thu Mar 03, 2011 6:52 pm
- Location: Area ???, under Bermuda Triangle
Re: Programming, computers, etc. [Serious]
I wish you luck.
BOTTOM TEXT
Proud poster of the 300kth post in GeneralThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
Re: Programming, computers, etc. [Serious]
I strongly dislike networking. Maybe that's because I've never done anything with it before
If two wrongs don't make a right, try three. - Laurence J. Peter
- Anonymously Famous
- JKL; Assassin

- Posts: 11413
- Joined: Thu Mar 03, 2011 6:52 pm
- Location: Area ???, under Bermuda Triangle
Re: Programming, computers, etc. [Serious]
I really appreciate those who understand and use it in their programming, because I like to use the Internet, and that's all about networking.
BOTTOM TEXT
Proud poster of the 300kth post in GeneralThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
- ThingerDudes
- ASDF Warlord

- Posts: 20868
- Joined: Sun Apr 12, 2009 4:12 am
- Location: close enough.
Re: Programming, computers, etc. [Serious]
had to make a server thing with sockets and encryptions and forking and crap for a project last year. Really really annoying. But fun once you get it working.

- Anonymously Famous
- JKL; Assassin

- Posts: 11413
- Joined: Thu Mar 03, 2011 6:52 pm
- Location: Area ???, under Bermuda Triangle
Re: Programming, computers, etc. [Serious]
Yeah. It sounds really annoying.
BOTTOM TEXT
Proud poster of the 300kth post in GeneralThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
- atomtengeralattjaro
- Site Admin

- Posts: 35622
- Joined: Wed May 23, 2007 3:43 pm
- Location: green
- Contact:
Re: Programming, computers, etc. [Serious]
what language/platform did you make it in/on?ThingerDudes wrote:had to make a server thing with sockets and encryptions and forking and crap for a project last year. Really really annoying. But fun once you get it working.

- ThingerDudes
- ASDF Warlord

- Posts: 20868
- Joined: Sun Apr 12, 2009 4:12 am
- Location: close enough.
Re: Programming, computers, etc. [Serious]
We had to do it in C. seg faults...so many seg faults...
and do documentation on it which was worth half the grade...
yeah...it was not a fun course.
and do documentation on it which was worth half the grade...
yeah...it was not a fun course.

- Anonymously Famous
- JKL; Assassin

- Posts: 11413
- Joined: Thu Mar 03, 2011 6:52 pm
- Location: Area ???, under Bermuda Triangle
Re: Programming, computers, etc. [Serious]
Writing documentation is a good skill to have.
BOTTOM TEXT
Proud poster of the 300kth post in GeneralThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
- atomtengeralattjaro
- Site Admin

- Posts: 35622
- Joined: Wed May 23, 2007 3:43 pm
- Location: green
- Contact:
Re: Programming, computers, etc. [Serious]
[continuing from the daily thread]
it occured to me that a 2-dimensional array is not the same as an array of arrays, because in the latter, you might be able to add arrays of varying size to an array of arrays, as opposed to a 2D array, which has only 2 dimensions.
a.)
b.)
i just checked, and it turns out java's syntax in arrays differs from C# in the following way:
java:
however, in C#:
Conclusion: double brackets like this: [][] are the only way to create a 2D array in Java, and are also able to create an array of arrays, but they only mean an array of arrays in C#.
also, accessing 2D arrays in Java is not possible with the C# syntax [,] and [2,3]
and accessing 2D arrays in C# is not possible with the Java syntax [2][3].
it's not all that complicated, i just kinda overcomplicated it, but i wanted to see how they really differ, because i've always thought the syntax of C# and Java are very similar on this basic level. Apparently not.
it occured to me that a 2-dimensional array is not the same as an array of arrays, because in the latter, you might be able to add arrays of varying size to an array of arrays, as opposed to a 2D array, which has only 2 dimensions.
a.)
Code: Select all
X X X X X X X X
X X X X X X X X
X X X X X X X X
X X X X X X X X
Code: Select all
X X X X
X
X X X X X X X X X X X
X X X X X X X X
java:
Code: Select all
int[][] a = new int[3][2]; //okay (2D array, not an array of arrays)
a[0][0] = 1; //cool
a[0,0] = 1; //not cool
int[,] c; //doesn't compile
int[][] b = new int[3][]; //okay (a 3 sized array of integer arrays)
b[0] = new int[2]; //okay (let the first element in the 3-sized array be a 2-sized int array)
b[0][1] = 1; // let the second element of the first element of the b array be 1.
however, in C#:
Code: Select all
int[,] a = new int[2, 2]; // okay
a[0, 1] = 87; //okay
a[0][1] = 44; //wrong
int[][] c = new int[3][2]; //NOT okay
int[][] b = new int[3][]; //okay (a 3 sized array of integer arrays)
b[0] = new int[2]; //okay (let the first element in the 3-sized array be a 2-sized int array)
b[0][1] = 1; // let the second element of the first element of the b array be 1.
also, accessing 2D arrays in Java is not possible with the C# syntax [,] and [2,3]
and accessing 2D arrays in C# is not possible with the Java syntax [2][3].
it's not all that complicated, i just kinda overcomplicated it, but i wanted to see how they really differ, because i've always thought the syntax of C# and Java are very similar on this basic level. Apparently not.

- Anonymously Famous
- JKL; Assassin

- Posts: 11413
- Joined: Thu Mar 03, 2011 6:52 pm
- Location: Area ???, under Bermuda Triangle
Re: Programming, computers, etc. [Serious]
Oh, they're similar, just not exactly the same. On a conceptual level, a 2d array is just an array of arrays with the lengths enforced. There are several languages where 2d arrays aren't explicitly possible - You have to enforce the lengths yourself. This can be tricky in languages that have arrays of modifiable length, like the Python list. Just do a myGrid.append(x) and you've messed up your 2d array.
Of note: Last week, for the first time in my memory, I had a problem in which a 3d array made sense (more accurately, a Python dictionary (named array) of lists of lists).
Of note: Last week, for the first time in my memory, I had a problem in which a 3d array made sense (more accurately, a Python dictionary (named array) of lists of lists).
BOTTOM TEXT
Proud poster of the 300kth post in GeneralThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
- atomtengeralattjaro
- Site Admin

- Posts: 35622
- Joined: Wed May 23, 2007 3:43 pm
- Location: green
- Contact:
Re: Programming, computers, etc. [Serious]
ha, stacking dimensions is fun
are you saying that there are no real arrays in python?
It is my understanding that arrays (and i mean real arrays, forced and fixed) are good because it is extremely easy for the computer to index them in the memory. All it needs to do is get the address of the beginning, and then add the length of an item, times the index requested. If there are structs in the array, they all have the same length, and if there are objects, it's only their reference stored there anyway, and those are of the same length too. As opposed to lists, where you'd need to step through a bunch of them in different places just to get to the n'th element.
are you saying that there are no real arrays in python?
It is my understanding that arrays (and i mean real arrays, forced and fixed) are good because it is extremely easy for the computer to index them in the memory. All it needs to do is get the address of the beginning, and then add the length of an item, times the index requested. If there are structs in the array, they all have the same length, and if there are objects, it's only their reference stored there anyway, and those are of the same length too. As opposed to lists, where you'd need to step through a bunch of them in different places just to get to the n'th element.

- Anonymously Famous
- JKL; Assassin

- Posts: 11413
- Joined: Thu Mar 03, 2011 6:52 pm
- Location: Area ???, under Bermuda Triangle
Re: Programming, computers, etc. [Serious]
Python types can change on a whim, and Python lists don't enforce type. There is an array class that enforces type, and it's more memory efficient than lists, but it doesn't have fixed size.
BOTTOM TEXT
Proud poster of the 300kth post in GeneralThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
Re: Programming, computers, etc. [Serious]
Oh the woos of a dynamic language...
If two wrongs don't make a right, try three. - Laurence J. Peter
- Anonymously Famous
- JKL; Assassin

- Posts: 11413
- Joined: Thu Mar 03, 2011 6:52 pm
- Location: Area ???, under Bermuda Triangle
Re: Programming, computers, etc. [Serious]
I like dynamic languages.
BOTTOM TEXT
Proud poster of the 300kth post in GeneralThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
- klinscy
- ASDF Worshipper

- Posts: 445
- Joined: Tue Jan 17, 2012 10:05 pm
- Location: Morgues, graveyards, hospitals, post-apocalyptic L.A.
Re: Programming, computers, etc. [Serious]
Dynamic = more complicated???
Captain Kirk wrote:"Very funny, Scotty. Now beam down my clothes."
Best acronym EVERZim wrote:Now, now, GIR. Movies don't create psychos. Movies make psychos more creative.
atomtengeralattjaro wrote: Effectively removed. Again, simply, essentially deleted.
- Anonymously Famous
- JKL; Assassin

- Posts: 11413
- Joined: Thu Mar 03, 2011 6:52 pm
- Location: Area ???, under Bermuda Triangle
Re: Programming, computers, etc. [Serious]
Nope. Not as efficient, but you don't need to declare types or initiate variables usually.
a = "2"
a = int(a)
No error, because the type can change.
Also, Python and some other related languages can have multiple return values from functions, which I think is cool.
a = "2"
a = int(a)
No error, because the type can change.
Also, Python and some other related languages can have multiple return values from functions, which I think is cool.
BOTTOM TEXT
Proud poster of the 300kth post in GeneralThingerDudes wrote:The only reasonable amount of Nutella is infinity. Everything else is too little.
- atomtengeralattjaro
- Site Admin

- Posts: 35622
- Joined: Wed May 23, 2007 3:43 pm
- Location: green
- Contact:
Re: Programming, computers, etc. [Serious]
now THAT would be a good thing even in non-dynamic languages. Anytime I have to give multiple results, i need to use out parameters or wrap them in some class. How does it work in python? i mean how do you invoke a method that has multiple return parameters, where do you put the results?Anonymously Famous wrote:multiple return values from functions

