User loginNavigation |
LtU ForumA name for this form of variable capture?I have a question, which has arisen after running into an unexpected variable capture in a Python program I am working on. Here is a sample:
def codeExample1(hashTable):
def makeGenerator():
for keyName in hashTable:
def valueGenerator():
for keyValue in hashTable[keyName]:
yield keyValue
yield (keyName,valueGenerator())
return makeGenerator()
Now, I was expecting What occurred instead was that To correct this unexpected behavior, one would rewrite
def codeExample1(hashTable):
def makeGenerator():
for keyName in hashTable:
def valueGenerator(_keyName):
for keyValue in hashTable[_keyName]:
yield keyValue
yield (keyName,valueGenerator(keyName))
return makeGenerator()
So that was a bit of a long lead in, but what I'm trying to get at is what is the name for the type of variable capture exhibited by Python in this example and what is the name of the variable capture I was expecting to occur? Barendregt's ConventionHi, I am doing some proofs on a calculus with existential types and I am fairly liberally applying Baredregt's convention (approximately that bound variables are distinctly named). My assumption is that I have to justify using this convention and that that justification is along the lines of 'the rules of the calculus abide by the convention'. However, I can not find any information about a formal way of justifying this. Does anyone have experience of this, or pointers to relavent papers? Thanks, Nick Don't try FP in industry!I'd like to tell a story. I'm an engineer working in the embedded world on compilers and simulators. Bored by the conservative approach to technology that I saw in companies, I started to learn Haskell/OCaml few years ago. It has been a valuable experience, especially for types. Then, I tried to build a small product. I selected OCaml for practical reasons. I wrote a part of a binary translator. The reuse is great, and the code is amazingly short.. I then explained what I had done to my team. But during a discussion with my boss, I was told that "exotic languages are very similar to exotic holiday locations. You pay a premium to go there, but the only thing that is sure is that you will come back. Quite often, the only tangible trace of your stay is what you let in the hotel bin: an empty bottle of water and some papers. Please rewrite your stuff in C." My conclusion is -- (1) I won't ever go on holiday with my boss and (2) I'm on the job market :) Anybody who had a better experience? Correct mathematical symbol to represent "subtype"If this question doesn't make sense, it's probably because I might be confused with the term subtype. What is the correct mathematical symbol for subtype ?
Thanks. (noob question) method parameters in co-and-contravariance issueIs co- and contravariance a concept related to inheritance or can it apply to normal method parameters ? e.g. In java
class Food{}
class Grass extends Food {}
class Antelope extends Food {}
public class Main2
{
public static void main(String[] args) {
Main2.eat( new Food() );
Main2.eat( new Grass() );
Main2.swallow( new Food() ); // compile-time error
Main2.swallow( new Grass() );
}
public static void eat( Food f ) {}
public static void swallow( Grass f ) {}
}
Am I correct in my reasoning ? Thanks Interesting old gem: Prop does pattern matching in C++I wonder why I haven't heard more about Prop. It lets you do ML-style pattern matching in C++. Perhaps a nifty way to sneak in a little functional programming at work. Cyclic Proofs for First-Order Logic with Inductive DefinitionsCyclic Proofs for First-Order Logic with Inductive Definitions, James Brotherston, in Proceedings of TABLEAUX 2005
This technique of making potentially cyclic proof-graphs is really nice since it makes the connection between recursive definitions in a functional programming language and a proof structure very obvious. There is no need to specify the inductive principle ahead of time, you can simply structure the proof tree as you would your functional code. By Gavin Mendel-Gleason at 2008-01-28 20:33 | LtU Forum | login or register to post comments | other blogs | 4939 reads
Fortress PresentationI've seen Fortress come upon the main page a few times, so I thought some people might be interested in a Fortress presentation by Guy Steele. I imagine there is nothing new for people following the language, but for those, like myself, who don't, it makes for a nice overview. For instance, it explains how they are doing entry of that crazy mathematical notation. I also found the explicit juxtaposition operator fascinating, though most likely I just haven't run across it's previous incarnations before. VM's... What's the best?I want to start making a compiler for a little programming language that I have in mind. I think that doing it right would teach me lot of new things. I want to target the JVM's bytecode using Jasmin or Jamaica but I want to know your opinions... Is there another good choice to generate bytecode from the opcodes for the JVM? What about other VM's? CLR is not as portable as JVM... I used Parrot once but i didnt like it in that time. Do you know other options? Axioms and Theorems for a Theory of Arrays
Axioms and Theorems for a Theory of Arrays
|
Browse archives
Active forum topics |
Recent comments
8 weeks 1 day ago
8 weeks 1 day ago
8 weeks 2 days ago
8 weeks 2 days ago
8 weeks 6 days ago
8 weeks 6 days ago
9 weeks 5 hours ago
9 weeks 9 hours ago
9 weeks 10 hours ago
9 weeks 10 hours ago