Reputation: 10 Tradesman
- Active Posts:
- 314 (0.17 per day)
- 26-February 09
- Profile Views:
- Last Active:
- Jun 01 2012 07:01 PM
- OS Preference:
- Favorite Browser:
- Favorite Processor:
- Favorite Gaming Platform:
- Your Car:
- Dream Kudos:
Posts I've Made
Posted 14 May 2012Coming from the Java world I can say that methods called .add() etc are a massive pain in the ass in terms of readability (and writability). As you have sometimes very long expressions, operator overloading looks like it should do, whereas with methods you end up with massive amounts of nested method calls that are horrible in almost every way.
This consistency is what languages should be all about, imho. Programs are the direct products of thoughts, and if your program (ie syntax) isn't consistent, how then can your thoughts?
I definitely hear you on the ... annoying bit - I got to a point in one of my projects where I simply could not stand it. I have on disk a small little script-thing-that's-technically-not-a script that will expand the macro of operator overloading for me (given precedences) and leave a commented 'overloaded' version above it. I know it's a pain, but infix is just too ambiguous. Without knowing how a certain language/compiler handles precedence, it is impossible to know what will happen. God forbid you needing to debug it.
Much of what we do nowadays is built off of what are essentially text-expanding macros, so I don't see why doing a little bit of the macro thing ourselves is such a sore point.
AdamSpeight2008, while your implementation of op. overloading for settings is clever, it seems like it's pushing on ambiguous as to what it actually does (comments aside). The use of methods is simply more stable and understandable (when formatted nicely, it rather resembles LISP).
On the flip side, BigInteger. It's obvious that languages shouldn't restrain programmers in their jobs, but... I don't know. For the few applications that make consistent sense (mathematical wrappers, such as numbers, matrices, etc.), I don't know if it's worth it to have such dangerously ambiguous code when it is so easy to write an expander.
Posted 12 May 2012
Posted 5 Apr 2012======================================================
Perhaps it would be best if I describe what exactly I'm trying to do.
I have a function whose signature is char* modify(char* original, char* modifier, int mod_size), where original is a variable-length string (guaranteed to be divisible into bytes) and modifier is a 'string' of 'bytes', where I'm actually trying an attempt at a bitstring. The trick is that I know for a fact that modifier will never be divisible into bits, and will usually be much smaller than original. In the case that it's smaller, I need something like this to happen:
0100100101011101 (original, 2 bytes long)
0110110110110110 (modifier, 3 bits long, repeated and truncated to the length of the bitstream)
(some logical operation) (modified, 2 bytes long)
Does anyone know how I can effect this?
Don't get stuck on array notation or any kind of syntax. Concentrate on whatever problem you're trying to solve.
It seems that I may have a shred of wisdom in me yet.
mod_size is an integer length of the modifier-bitstream.
Posted 5 Apr 2012I'm sorry that I didn't really clarify, but I need to both read and write individual bits in a byte (ideally an arbitrary-length bitstream). Sorry baavgai, but that BIT macro is just that - a macro, and can't act as an Lval.
AND OHMYGOODNESS ishkabible that look so awesome. Unfortunately, C doesn't 'do' templates at all - and I'd really like to stick to ANSI C.
jimblumberg has basically what I need, but is there any way to make it so we can access the bits through array notation? Obviously we can't just throw it in an array, because bitfields don't have their own address to dereference. Is there any way we can use void*?
- Member Title:
- D.I.C Regular
- 20 years old
- March 29, 1993
- [quote name='gabehabe' post='690163' date='1 Jul, 2009 - 04:28 AM'][quote name='supersloth' post='689756' date='30 Jun, 2009 - 11:10 PM'][quote name='gabehabe' post='689426' date='30 Jun, 2009 - 10:25 AM'][quote name='KYA' post='689259' date='30 Jun, 2009 - 02:47 PM'][quote name='supersloth' post='689173' date='30 Jun, 2009 - 07:27 AM'][quote name='gabehabe' post='689026' date='30 Jun, 2009 - 03:34 AM'][quote name='supersloth' post='688649' date='29 Jun, 2009 - 11:38 PM'][quote name='supersloth' post='688255' date='29 Jun, 2009 - 07:57 AM'][quote name='gabehabe' post='688027' date='29 Jun, 2009 - 02:06 AM'][quote name='supersloth' post='687827' date='29 Jun, 2009 - 02:04 AM']this thread fucking sucks.[/quote][/quote][/quote][/quote][/quote][/quote][/quote][/quote][/quote][/quote]
- Years Programming:
- Programming Languages:
- [X]HTML, JS, C/ObjC/C++, Visual Basic, C#, Java, Python, Chef (it's fun!), LISP (best damn language I've ever worked with - seriously), others?
- Website URL: