[Learn Note]2012-01-29

 

1 Emacs Lisp Date Time Formats

Elisp provides a very convenient function format-time-string for printing data time. For example, you can write a command to print date in the yyyy-mm-dd format using (insert (format-time-string "%Y-%m-%d")). Here's the full code:

(defun insert-date ()
  "Insert current date yyyy-mm-dd."
  (interactive)
  (when (region-active-p)
    (delete-region (region-beginning) (region-end) )
    )
  (insert (format-time-string "%Y-%m-%d"))
  )

2 C # and closure

Closure variables have actually departing from the scope, but because the presence of context and scope, so that the object can continue to use a functional environment in which the above-defined in the current environment.

public class TCloser
    {
        public Func<int> T1()
        {
            var n = 999;
            return () =>
            {
                Console.WriteLine(n);
                return n;
            };
        }
    }
    
    class Program{
        static void Main(){
            var a =new TCloser();
            There a.t1 b = ();
            Console.WriteLine(b());
        }
    }

From the above code we can see, the variable n is actually a part of the local variables T1, it would have been life-cycle should be accompanied by the end of the function call T1 is freed, but here we are in the commission b returned still call it, here is the closure of the show out of power, because the code fragment anonymous delegate T1 calls returned, we used the n, and the compiler view, these are legal because the commission returned b T1 context exists and functions, that is to say to allow the use of anonymous delegates b in its function or class of local variables inside, then through a series of compiler operation (specifically an operation we for later) so called in the function of T1 b local variables are automatically closed so that the local variables meet new scope.

So if you see .net closures, as you can understand it as js, since the returned objects are anonymous function generated in the function T1, so it belongs to a property corresponding to T1. If you put the object level T1 up to the next level on a good understanding, here is the equivalent of a T1 class, and anonymous objects returned is a property of T1, the properties concerned, it can call it Storage any other property or method of the object T1 includes other attributes TCloser T1 inside the object registered. If the anonymous function other objects will be returned to the calling, the method of working life T1 compiler automatically anonymous function used in local variables and automatically upgrade the life cycle of the same anonymous function, so called closed .

See IL code of the original language.

3 Bootstrapping

http://en.wikipedia.org/wiki/Bootstrapping

a self-sustaining process that proceeds without external help.

Bootstrap auxiliary program.

4 emacs searching

  • Increament searching
    C-S C-Shift-W
  • Searching Using TAGS
    • Using ETAGS to creat the etags files
    • Using M-. to search for a definition
    • Using visit-tags-table to refresh the TAGs file
    • sams-cm-rotate and sams-cm-save-point
  • grep-find
    • How to setup grep within the windows
      Copy grep.exe and find.exe from git to the bin directionary of the emacs Add the bin of the emacs to the path like below: set path=<path of bin>;%path%

Author: Jalen Wang <[email protected]>

Date: 2012-01-30 21:44:46

HTML generated by org-mode 6.33x in emacs 23

Reproduced in: https: //www.cnblogs.com/jalenwang/archive/2012/01/30/2332444.html

Guess you like

Origin blog.csdn.net/weixin_34240657/article/details/93512522