小编Ren*_*nzo的帖子

如何编写/引用PHP可调用函数易于管理我的IDE

当我必须编写对可调用函数的引用时,我使用PHP的标准语法定义为:

PHP函数的名称作为字符串传递.可以使用任何内置或用户定义的函数[...省略...].

实例化对象的方法作为包含索引0处的对象和 索引1处的方法名称 (aka字符串)的数组传递.

通过传递类名 (仍然是字符串) 而不是索引0处的对象,也可以传递静态类方法而无需实例化该类的对象.

从PHP 5.2.3开始,也可以传递 (字符串) 'ClassName :: methodName'.

除了常见的用户定义函数,匿名函数也可以传递给回调参数.

对于诸如函数名重构查找用法之类的操作,所有这些方式都不是"IDE友好的" .

在我的回答中,我提出了一个解决方案,但是还有其他方法可以应用,甚至是完全不同的,允许IDE"找到"方法的调用?

php ide closures callable anonymous-function

16
推荐指数
1
解决办法
408
查看次数

Xcode 7 Swift 2无法实例化通用UITableViewController的UIViewController子类

我有一个通用类:

class PaginatedTableViewController
  <GenericElement, Source: PaginationDataSource 
     where Source.PaginatedGenericElement == GenericElement>:
  UITableViewController
Run Code Online (Sandbox Code Playgroud)

另一个我试图从故事板中实例化:

class CandidatesTableViewController: 
   PaginatedTableViewController<Match, MatchPaginationDataSource>
Run Code Online (Sandbox Code Playgroud)

CandidatesTableViewController在故事板Custom Class下拉菜单中找不到.如果我强制它然后在代码中转换我的控制器,应用程序在运行时崩溃抱怨我的控制器(应该是CandidatesTableViewController实例)实际上是一个UITableViewController实例.

Interface Builder文件中的未知类_TtC21MyProjectName29CandidatesTableViewController.无法将'UITableViewController'类型的值(0x1040917f8)转换为'MyProjectName.CandidatesTableViewController'(0x1013a9890).

在我的项目中,这个控制器嵌入另一个控制器,这就是我投射它的原因:

tableViewController = (segue.destinationViewController as! CandidatesTableViewController)
Run Code Online (Sandbox Code Playgroud)

有谁知道如何解决这个问题?

generics ios swift swift2

6
推荐指数
1
解决办法
591
查看次数

有没有办法在Common Lisp中获取变量地址?

我正在尝试在Common Lisp上实现XOR链接列表,但我需要获取一个变量的地址来对其执行任何按位操作.有没有办法获取变量的内存地址,类似于python的id()函数?

lisp common-lisp memory-address xor-linkedlist

5
推荐指数
1
解决办法
391
查看次数

通过命令行将文件添加到目标 xcode

我可以使用xcodebuild. 我想在构建之前将文件添加到项目中,目前我将文件拖放到项目中,同时它也会添加到项目中。其他选项是“右键单击”和“将文件添加到项目”

但是如何通过命令行添加文件呢?cp命令不会将文件添加到项目/目标。

xcode cmd xcodebuild ios

5
推荐指数
0
解决办法
716
查看次数

什么是 SBCL 在 macOS、Linux、FreeBSD 上的路径名通配符约定?

今天在我的 Mac 上试用 Lisp,我发现以下内容有点令人迷惑:

$ sbcl
This is SBCL 1.4.14, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses.  See the CREDITS and COPYING files in the
distribution for more information.

* (directory "*")
NIL

* (directory "*.*")
(#P"/private/tmp/sbcl/quicklisp.lisp" #P"/private/tmp/sbcl/test1.lisp"
 #P"/private/tmp/sbcl/test2.lisp")
Run Code Online (Sandbox Code Playgroud)

在 macOS、Linux、FreeBSD 上,可能还有大多数其他类 UNIX 系统,*代表所有文件。我只见过*.*在 …

lisp sbcl common-lisp

5
推荐指数
1
解决办法
134
查看次数

测试符号是否是Common Lisp中的defstruct名称

是否有一种更简单的方法来测试符号是否是结构的名称而不是:

(fboundp 'make-symbol)
Run Code Online (Sandbox Code Playgroud)

common-lisp

4
推荐指数
1
解决办法
174
查看次数

如何防止粘液在某些错误上启动sldb?

从连接Slime的Clack/Hunchentoot提供大文件时,我有时会看到错误消息,如SB-IMPL :: SIMPLE-STREAM-PERROR"无法写入~s"......这些是由浏览器过早掉线造成的(这完全可以).问题是,每次发生时,SLDB都会弹出.这很烦人.

有没有办法可以抑制SLDB中的某些错误,如上所述?我仍然希望在错误日志中看到它们,但绝对不是在SLDB中.

emacs sbcl common-lisp slime hunchentoot

4
推荐指数
1
解决办法
213
查看次数

Common Lisp使用类型声明进行优化的最佳实践

我有一个Common Lisp函数,它合并了两个有序的符号列表,没有重复(两个有序集):

(defun my-merge (x y)
  "merge two lists of symbols *already sorted and without duplicates*
   (and return the resulting list sorted and without duplicates)"
  (let* ((first (cons nil nil))
         (last first))
    (loop while (and x y)
       for cx = (car x)
       for cy = (car y)
       if (string= cx cy)
       do (setf x (cdr x))
       else if (string< cx cy)
       do (rplacd last (cons cx nil))
       and do (setf last (cdr last) 
                    x (cdr x))
       else do (rplacd last …
Run Code Online (Sandbox Code Playgroud)

optimization common-lisp compiler-optimization

4
推荐指数
1
解决办法
974
查看次数

获取枚举大小和名称作为通用参数传递

看看下面的代码:

uses
  TypInfo, Dialogs, Classes, Generics.Collections, ADODB, DB, SysUtils;

type
  TTable_1 = (ID, FName, LName, FatherName);

type
  TBaseTable<TableType> = class(TADOQuery)
  public
    constructor Create(AOwner: TComponent); Override;
    procedure Select(DS: TDataSource);
  end;

implementation

{ TBaseTable<TableType> }

constructor TBaseTable<TableType>.Create(AOwner: TComponent);
begin
  inherited;
  Self.Connection := DataModule3.ADOConnection1;
  Self.Connection.Connected := True;
end;

procedure TBaseTable<TableType>.Select(DS: TDataSource);
var
  Query: string;
  EnumIndex: Byte;
begin
  EnumIndex := 0;
  Query := 'SELECT ';
  while (GetEnumName(TypeInfo(TableType), EnumIndex) <> UnitName) do
  begin
    Query := Query + GetEnumName(TypeInfo(TableType), EnumIndex) + ',';
    Inc(EnumIndex);
  end;
  Query := …
Run Code Online (Sandbox Code Playgroud)

delphi generics orm enums

3
推荐指数
1
解决办法
730
查看次数

Web应用程序中符号上的Common Lisp相等

以下功能:

(defun check-for-arrow (x)
  (format t "**~s**~s**~s**~s**"
          (length (string x))
          x
          (eq x '->)
          (and (eq (elt (string x) 0) #\-)
               (eq (elt (string x) 1) #\>))) ; for debug
  (eq x '->))
Run Code Online (Sandbox Code Playgroud)

从REPL调用时,用:

(check-for-arrow '->)
Run Code Online (Sandbox Code Playgroud)

打印,跟踪:

0> Calling (CHECK-FOR-ARROW ->) 
**2**->**T**T**
<0 CHECK-FOR-ARROW returned T
Run Code Online (Sandbox Code Playgroud)

相反,当在Hunchentoot Web应用程序内部调用时,在表单中读取数据时,通过符号" - >"调用时,将打印:

0> Calling (NORMALIZER::CHECK-FOR-ARROW ->) 
**2**->**NIL**T**
<0 NORMALIZER::CHECK-FOR-ARROW returned NIL
Run Code Online (Sandbox Code Playgroud)

Lisp是Clozure Common Lisp.

这取决于不同的实习符号方式吗?可以在符号上使用'eq',或者我必须转换字符串中的箭头并检查字符串是否相等?

谢谢.

lisp symbols equality common-lisp hunchentoot

3
推荐指数
1
解决办法
221
查看次数