148 karma · joined February 20, 2007
For example, I find printf-like debugging and using stack traces from Valgrind to be very useful for debugging my own code; however, at work, when I have no idea where the problem is, something like gdb or the debugger of Visual Studio really comes in handy.
First, the variables used in the comprehension would be defined locally, with the right types.
Second, we would need an overloaded template function, named something like "constructor" to abstractly represent a constructor for some arbitrary object. Here is how the constructor function works: for N arguments, all taken by reference, it allocates an array of N void * pointers (or sufficiently large slot sizes + proper alignment to hold any pointer type), and returns a pointer to the first slot in that array as some member in an instantiated template, where one of the parameters of the template contains all the info of the types of the constructor parameters. It also initializes each slot of the array to be the address of the local variable passed in to the constructor function by reference. So, if the following is my setup:
int foo;
float bar;
constructor<std::pair>(foo, bar)
returns an object of type Constructor<std::pair, Slot<Base<int>,float> >, where the object contains a pointer to the first slot in the array. This type and the array contain all the info we need to construct an std::pair<int,float>.The comprehensions would likely require an new iteration mechanism. This was the case in my thesis project, as a cursor-based iterator, while being able to represent the iteration aspect of this, is unable to fully represent the pattern-matching/destructuring bind operations. The tricky part is to make it so that one can advance multiple loops in sequence.
When we know that we can enter the body of the inner loop that would normally represent the innermost loop in an imperative implementation of the same operation being performed by the comprehension then we can use the pointer table to bind values to local variables, and then use a compile-time created function from the Constructor type to yank out those values all at once, impose the proper types using a cast on the void * pointers, and then construct the thing we want to add into our final list.
The project page is http://www.grailplus.org.
Obviously, another way would be Hipmunk getting authorization to use Southwest's data from Southwest.
#include <stdio.h>
int main(void) {
int a, b, c;
int d = (a = 1, b = 2, c = 3, a + b + c);
int e = (({int f = 1; e = f;}), e += 1);
printf("d is %d \n", d);
printf("e is %d \n", e);
return 0;
}
Edit: I just realized how strange the line e = ... is. I wonder if it yields different results with different compilers.I suspect that you can find someone with an anecdote describing a perfectly functioning mac and one that exploded. The same such anecdotes likely also exist for people running Thinkpads, Latitudes, et al.
As I tend to work with php a lot I often think about how to make PHP better and given that I like functional programming, more functional. Here are a few of the ideas I've thought up:
Putting a $ in front of a symbol, e.g. $var is equivalent to defining and requiring that variable to be within, and only within, the current lexical scope. Given that within PHP, if/for/while/switch statements don't create new lexical scopes, everything would still work as is. The benefit would be to say that $ is no longer required such that variables could now be accessed without $, as is the case with functions. A symbol without a $ would be one that goes to each parent scope and either looks for the existence of a symbol. This is consistent with how current PHP functions works because currently all PHP functions belong to the global namespace, ie: they all are part of the root scope. So, this establishes that variables don't need to be preceded by $, and that $ is an operator that says look at the local symbol table for variables.
The above model sets the stage for variables being passed down through child scopes and functions as well. That would all for proper closures that don't require parent scope variables to be used be explicitly defined. This also means that functions defined within functions (legal PHP) would not be put into the global namespace (this is inconsistent with previously versions of PHP).
Finally, most symbols will either be values (in the cases of scalars, arrays, etc), instances (in the case of class instances), references, resources (function resources, other resources), or a few other data types that PHP currently supports. So, the symbol 'substr' is a function resource to the substr() function and '$substr' is only defined within the root scope as the same function resource. The idea of function resources is consistent with how PHP 5.3 implements anonymous functions.
ex) If within the current scope one defines '$substr', then both 'substr' and '$substr' will point to that something else within the current scope and all subscopes.
ex) If '$substr' is not defined in the current scope and one redefines 'substr' in the current scope then the actual 'substr' reference is changed for all scopes after that.
</braindump>
I went back a few articles and found this: http://alexicalmistake.com/2008/06/scheme-parser-combinators..., to which I've concluded that I might be using combinators in my interpreted parsing language because every operator (such as 'repeat' or 'find-next') returns a function that performs the operations, but I am still a bit unclear.
If anyone is interested, I wrote a bit about them and gave an example of the parse tree created here: http://ioreader.com/2009/01/01/common-lisp-recursive-descent... As I am new to common lisp (reading ANSI CL, actually, although I've been playing with things not yet mentioned in the book!), the code leaves a lot to be desired.
Otherwise, very interesting article. These are the subjects that interest me most and approachable articles like these help me a lot.
Here is an old and slightly modified mysql result set iterator that fits the purposed of the newer code that makes this example nice: http://codepad.org/nmD4pDES
Here is a windowing iterator, it gives the person the ability to shift and pop elements from the inner iterator, thus narrowing the field that the iterator goes over: http://codepad.org/IsE5U7cw
We can now do the following... http://codepad.org/nP0EEKxT
Clearly our cellular plans suck, but the U.S.'s intellectual property laws remain more restrictive than ours (for now).
1) Loop over MySQL result set in GetArray
2) Loop over array of results to format them in GetVideos
3) assumed loop over results to eventually display them to the user.
All three steps could be accomplished at the same time by simply using iterators.
The one deterrent I can see to adoption is that police might not like it. No longer would they be able to shoot someone's tires out or put spikes out on a road to slow them down.