小编use*_*344的帖子

如何理解Anorm解析器?

来自http://www.playframework.org/documentation/2.0/ScalaTodoList

"〜"做了什么以及为什么我在地图之前不需要一个点?

val task = {
  get[Long]("id") ~ 
  get[String]("label") map {
    case id~label => Task(id, label)
  }
}
Run Code Online (Sandbox Code Playgroud)

谢谢你的帮助.

anorm playframework-2.0

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

在GraalVM体系结构上实现编程语言

在GraalVM架构上实现编程语言的(架构)差异是什么 - 特别是在使用Sulong的Graal,Truffle和LLVM之间?

我计划在GraalVM体系结构上重新实现现有的静态类型编程语言,这样我就可以从Java中使用它而不会有太多麻烦.

目前有三种选择:

  • 发出JVM字节码
  • 写一个松露口译员
  • 发出LLVM bitcode,使用Sulong在GraalVM上运行它

在此输入图像描述

graalvm

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

与Ada一起使用FastCGI

我找到了http://support.zeus.com/zws/examples/2005/12/16/hello_world_in_perl_and_c,这两个例子正在运行.

现在我为Ada尝试了这个,我从2天后就无法完成它.

fcgi_stdio.ads

with Interfaces.C;
with Interfaces.C.Strings;

package fcgi_stdio is
    function FCGI_Accept return Interfaces.C.int;
    pragma Import (C, FCGI_Accept, "FCGI_Accept");

    procedure FCGI_printf (str : Interfaces.C.Strings.chars_ptr);
    pragma Import (C, FCGI_printf, "FCGI_printf");
end fcgi_stdio;
Run Code Online (Sandbox Code Playgroud)

test.adb

with fcgi_stdio;
with Interfaces.C;
with Interfaces.C.Strings;

procedure Test is
begin
    while Integer (fcgi_stdio.FCGI_Accept) >= 0 loop
        fcgi_stdio.FCGI_printf (Interfaces.C.Strings.New_String ("Content-Type: text/plain" & ASCII.LF & ASCII.LF));
        fcgi_stdio.FCGI_printf (Interfaces.C.Strings.New_String ("Hello World from Ada!" & ASCII.LF));
    end loop;
end Test;
Run Code Online (Sandbox Code Playgroud)

当我在控制台中运行它时,我收到以下错误:

$ ./test
raised STORAGE_ERROR : stack overflow or erroneous …
Run Code Online (Sandbox Code Playgroud)

c fastcgi ada mod-fcgid mod-fastcgi

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

Java调用Clojure函数时如何处理不同的返回类型?

我想binomial从 Java 调用 Clojure 函数。我遇到的一个问题是它返回不同的数据类型,或者long(例如,n=5,k=3)或BigInt(例如,n=20,k=10)。在Java方面,它应该是一个BigInteger。

至少有两种选择可以克服这个问题,哪一个更好?

  1. 强制 Clojure 函数返回 BigInt (我不知道这是否可能。我尝试了类型提示,但它仍然返回longor BigInt)。
  2. 在Java中,对返回值使用模式匹配并检查类型,然后进行适当的转换。

克洛尤尔

(ns sample.hello
  (:import (clojure.lang BigInt)))

(defn binomial
      "Calculate the binomial coefficient."
      ^BigInt [^Integer n ^Integer k]
      (let [a (inc n)]
           (loop [b 1
                  c 1]
                 (if (> b k)
                   c
                   (recur (inc b) (* (/ (- a b) b) c))))))
Run Code Online (Sandbox Code Playgroud)

爪哇

public class Hello {
    public static final IFn binomial;

    static {
        Clojure.var("clojure.core", "require").invoke(Clojure.read("sample.hello"));
        binomial = Clojure.var("sample.hello", …
Run Code Online (Sandbox Code Playgroud)

java interop clojure

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

在Ada中从System.Address转换为Integer

在下面的例子中,我想知道,为什么line 17不起作用,但是line 18?我可以不System.Address直接转换为Integer(参见line 17)吗?

main.adb

with Ada.Text_IO;
with Ada.Unchecked_Conversion;
with System.Storage_Elements;

procedure Main is
   package SSE renames System.Storage_Elements;

   type Integer_Access is access Integer;
   I1_Access : Integer_Access := new Integer'(42);
   I1_Address : System.Address := I1_Access.all'Address;

   function Convert1 is new Ada.Unchecked_Conversion (System.Address, Integer);
   function Convert2 is new Ada.Unchecked_Conversion (System.Address, Integer_Access);
begin
   Ada.Text_IO.Put_Line (SSE.To_Integer (I1_Access'Address)'Img);
   Ada.Text_IO.Put_Line (SSE.To_Integer (I1_Access.all'Address)'Img);
   Ada.Text_IO.Put_Line (I1_Access.all'Img);
   Ada.Text_IO.Put_Line (Convert1 (I1_Address)'Img);  --  why does this NOT work?
   Ada.Text_IO.Put_Line (Convert2 (I1_Address).all'Img);  -- …
Run Code Online (Sandbox Code Playgroud)

memory-management ada memory-address

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

更改参数调用行为

是否可以从左到右而不是从右到左更改参数调用行为(第25行)?

底部的代码将3 2 1打印到控制台.

with Ada.Containers.Vectors;
with Ada.Text_IO;

procedure Main is

   package Vector is new Ada.Containers.Vectors (Positive, Integer);
   V : Vector.Vector;

   procedure A (X, Y, Z : Integer) is
   begin
      Ada.Text_IO.Put_Line (X'Img & Y'Img & Z'Img);
   end;

   function B return Integer is
      X : Integer := V.First_Element;
   begin
      V.Delete_First;
      return X;
   end;

begin
   V.Append (1);
   V.Append (2);
   V.Append (3);
   A (B, B, B);
end Main;
Run Code Online (Sandbox Code Playgroud)

parameters ada

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

在"="函数中检查空对象

我想写一个"="函数,它可以将A_Access与null对象进行比较.我如何编写"="函数,以便它可以工作?我试试看,见下文.

代码生成一个凸起的CONSTRAINT_ERROR:main.adb:14访问检查失败.

with Ada.Tags;
with Ada.Text_IO;

procedure Main is
   type A is tagged
      record
         a : Integer;
      end record;
   type A_Access is access all A'Class;

   function "=" (Left, Right : A_Access) return Boolean is
      use Ada.Tags;
   begin
      return (Left.all'Tag = Right.all'Tag and then Left.a = Right.a);
   end "=";
begin
   declare
      A_1 : A_Access := new A'(a => 1);
      A_2 : A_Access := null;
   begin
      if A_1 /= A_2 then
         Ada.Text_IO.Put_Line (":-)");
      end if;
   end;
end Main;
Run Code Online (Sandbox Code Playgroud)

我也尝试检查null,但随后,我得到了STORAGE_ERROR:堆栈溢出 …

null ada

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