问题列表 - 第15303页

tcl中proc语法的几种风格有什么区别?

我可以知道proc的sytanx是如何工作的.在...的背景下

- 记忆消费

- 传播

-scope of proc(本地/全球)

proc dosomething {} {
   #code here
}

proc dosomething { } {
    #code here
}

proc dosomething {
    #code here
}

proc dosomething args {
     #code here
}

proc ::dosomething {} {
     #code here
}
Run Code Online (Sandbox Code Playgroud)

等等.....

syntax tcl

0
推荐指数
1
解决办法
138
查看次数

如果在C++中有一个for循环,那么将方法声明为内联方法是否可以

我有一个如下所示的方法.for循环总是让编译器去"内联请求"吗?

inline void getImsiGsmMapFrmImsi
  (
    const string& imsiForUEDir, 
    struct ImsiGsmMap& imsiGsmMap
  )
{
    for (int i = 0 ; (unsigned)i < imsiForUEDir.length() - 1 ; i++)
    {
         imsiGsmMap.value[i] = imsiForUEDir[i] - '0' ;
    }
    imsiGsmMap.length = imsiForUEDir.length() - 1 ;
}
Run Code Online (Sandbox Code Playgroud)

c++ optimization loops inline

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

在什么版本的Python中设置了初始化语法

我今天才注意到这个功能!

s={1,2,3} #Set initialisation
t={x for x in s if x!=3} #Set comprehension
t=={1,2}
Run Code Online (Sandbox Code Playgroud)

它是什么版本的?我也注意到它已经设定了理解力.这是在同一版本中添加的吗?

资源

python

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

标记和扫描GC有什么问题?

我正在阅读Steve Yegge的"动态语言反击"谈话,其中有点批评标记和扫描的GC(通过该链接大约5-10%,"Pigs尝试飞行"幻灯片)他们有什么问题?

performance garbage-collection

8
推荐指数
3
解决办法
6768
查看次数

如何为TDictionary创建一个敏感的TEqualityComparer案例?

我有一个使用TDictionary的案例:

var D: TDictionary<string, integer>;
begin
  D := TDictionary<string, integer>.Create(TCustomEqualityComparer.Create());
  try
    D.Add('One', 1);
    D.Add('Two', 2);
    D.Add('Three', 3);

    showmessage(inttostr(D.Items['One']));
    showmessage(inttostr(D.Items['TWO']));
  finally
    D.Free;
  end;
end;
Run Code Online (Sandbox Code Playgroud)

Generics Defaults TEqualityComparer(Delphi)复制类TCustomEqualityComparer,对GetHashCode方法进行微小修改:

TCustomEqualityComparer = class(TEqualityComparer<string>)
public
  function Equals(const Left, Right: string): Boolean; override;
  function GetHashCode(const Value: string): Integer; override;
end;

function TCustomEqualityComparer.Equals(const Left, Right: string): Boolean;
begin
  Result := SameText(Left, Right);
end;

function TCustomEqualityComparer.GetHashCode(const Value: string): Integer;
begin
  Result := BobJenkinsHash(Value[1], Length(Value) * SizeOf(Value[1]), 0);
end;
Run Code Online (Sandbox Code Playgroud)

我希望TCustomEqualityComparer能够对键值执行不区分大小写的匹配.例如:

D.Items['TWO']
Run Code Online (Sandbox Code Playgroud)

但是,我收到"找不到项目"的例外情况.我使用的是Delphi 2010版本14.0.3513.24210.

有谁知道我的代码有什么问题?

delphi

10
推荐指数
2
解决办法
2864
查看次数

常量字符串地址

我的程序中有几个相同的字符串常量:

const char* Ok()
{
  return "Ok";  
}

int main()
{
  const char* ok = "Ok";
}
Run Code Online (Sandbox Code Playgroud)

是否保证它们具有相同的地址,即我可以编写以下代码吗?我听说GNU C++优化了字符串,所以它们具有相同的地址,我可以在程序中使用该功能吗?

int main()
{
  const char* ok = "Ok";
  if ( ok == Ok() ) // is it ok?
  ;
}
Run Code Online (Sandbox Code Playgroud)

c++ constants string-comparison

6
推荐指数
2
解决办法
328
查看次数

有没有办法轻松地将Ruby代码转换为PHP?

我们需要为我们客户的一个网站开发功能.但是,我们实际上已经在Ruby中准备好了代码.有没有办法直接将该ruby代码转换为PHP?

php ruby

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

Jquery UI对话框内的输入没有被发送?

我的对话框中的输入字段没有发布,我不知道为什么......

我已经在mac firefox和safari上测试了它,并且Windows IE和firefox具有相同的结果,所以我不认为它是浏览器,如果我禁用对话框,字段会发布.

我已经重新阅读了jquery ui docs并找不到我做错了什么......对话框似乎不太可能不支持输入.

这是我正在使用的代码的精简版本:

<script type="text/javascript">
 $(document).ready(function(){
  $("#dialog").dialog({
   autoOpen: false,
   buttons: {
    "OK": function() {
     $(this).dialog('close');
    }
   }
  });
  $("#publishSettings").click(function(){
   $("#dialog").dialog('open');
  });
 });
</script>

<form method="POST" action="publish.php">
 <input type="button" id="publishSettings" value="Publish Settings">
 <div id="dialog">
  Publish Date
  <input type="text" name="publishOn"><br>
  Unpublish Date
  <input type="text" name="unPublishOn">
 </div>
 <input type="submit" name="pubArticle" value="Publish">
</form>
Run Code Online (Sandbox Code Playgroud)

没什么不寻常的吧?为什么这不适合我!?

谢谢!

html forms post jquery-ui

18
推荐指数
2
解决办法
3万
查看次数

如何在Scala中打印地图

好吧,这个问题似乎真的很愚蠢,但我的观点是,如果你看一下Scala 2.7.6 API,他们就不推荐使用mappingToString方法了.因此,应该有更优雅的替代方案来打印自定义格式的Map.因为几乎任何目的,在Map中使用mkString的等价方法非常方便.

你们怎么看待它?除println外,打印地图的编码片段是什么?

formatting scala map

5
推荐指数
2
解决办法
2万
查看次数

如何使用Perl将一个文件的列替换为另一个文件的列?

假设文件1有两列,看起来像:

fuzz          n.  flowering shrub of the rhododendron family
dyspeptic     adj. bright blue, as of the sky 
dysplexi      adj. of Byzantium or the E Roman Empire
eyrie         adj. of the Czech Republic or Bohemia
azalea        adj. suffering from dyslexia
Czech         adj. suffering from dyspepsia
Byzantine     n. eagle's nest
azure         n. mass of soft light particle

文件2只有一个clumn,看起来像:

azalea
azure
Byzantine
Czech
dyslexic
dyspeptic
eyrie
fuzz

我希望文件1的第一列替换为文件2的列.因此,文件3应如下所示:

azalea        n.  flowering shrub of the rhododendron family
azure         adj. bright blue, as of the …

perl

0
推荐指数
1
解决办法
1116
查看次数