@Benjaminel: I'm trying to emulate the Python "with" style, which is more 
general-purpose than just files. I think that "using" in C# is similar, to take 
any given resource for a block, and then auto-close it for you at the end of 
that block.

@Others:

Thanks for the replies so far! So, I another question 

1\. Can you update the macro so that it can work without an "as X" clause?

eg, something like this:
    
    
    echo "I'm anywhere on the filesystem"
    
    with changeDir("/tmp/x"):
       echo "I am now under /tmp"
    
    echo "I'm back to where I was before"
    

Which then would expand to something along these lines:
    
    
    echo "I'm anywhere on the filesystem"
    
    var private_x = changeDir("/tmp/x")
    var private_y = my_enter(private_x)
    
    try:
       echo "I am now under /tmp"
    finally:
       my_exit(private_y)
    
    echo "I'm back to where I was before"
    

Would like to be able to have a "with" macro that supports both forms, based on 
whether there is an "as" clause.

Thanks! 

Reply via email to