различие между (defalias '(Функция символа 'B)) и (defalias ''B)

Это очень просто. предположим, клетка - это объект, положение которого нужно выяснить.

  UITableView* table = (UITableView *)[cell superview]; 
  NSIndexPath* pathOfTheCell = [table indexPathForCell:cell]; 
  NSInteger sectionOfTheCell = [pathOfTheCell section]; 
  NSInteger rowOfTheCell = [pathOfTheCell row];
24
задан Yoo 9 October 2009 в 20:51
поделиться

2 ответа

The two defalias usages are slightly different. The first links the function cell for 'backward-delete-char to that of 'delete-backward-char. The second links the 'search-forward-regexp to the function that is currently called by 're-search-forward.

The difference is that if you later change the definition of 'delete-backward-char, 'backward-delete-char will now have the new behavior. Whereas in the second case, changing the function for 're-search-forward has no effect on the behavior of 'search-forward-regexp.

Perhaps some ascii art can help:

+-------------------------+     +-----------------+
|#<subr re-search-forward>| <-- |re-search-forward|
+-------------------------+     +-----------------+
                        ^       +---------------------+
                        \------ |search-forward-regexp|
                                +---------------------+

+----------------------------+     +--------------------+     +--------------------+
|#<subr delete-backward-char>| <-- |delete-backward-char| <-- |backward-delete-char|
+----------------------------+     +--------------------+     +--------------------+

This documentation might help clear things up.

34
ответ дан 28 November 2019 в 23:49
поделиться

Ну, это действительно не то же самое ... Вот небольшая игра, в которую я только что играл:

(defun a () (message "hello"))
a
(a)
"hello"
(defalias 'b (symbol-function 'a))
(lambda nil (message "hello"))
(defalias 'c 'a)
a
(b)
"hello"
(c)
"hello"
(defun a () (message "howdy"))
a
(a)
"howdy"
(b)
"hello"
(c)
"howdy" ' c changed meaning, b did not...
2
ответ дан 28 November 2019 в 23:49
поделиться
Другие вопросы по тегам:

Похожие вопросы: