在我的 TODO 中有新项目,无法选择 F# 或 Nemerle。
我目前正在学习 F#,并且在 Nemerle 上有一些项目。
我喜欢 F# 方式,我喜欢默认缩进(我也希望 nemerle2 默认缩进),我喜欢 F# 的许多特性和魔力,但没有宏。
F# 的目标是 VS2010,也许(也许)更大的开发团队,它看起来像 Haskell(可以用它创建轻量级的 Linux 程序,而且很有趣)。
Nemerle 的目标是宏,我想我更喜欢 Nemerle 的一些语法。
大多数人都喜欢 C#...
- 所以语言必须是透视的
- 语法必须合乎逻辑、易于理解、简洁且功能强大(代码少)
- 它必须易于与 .NET 一起使用
- 所以我已经用这三个的选择关闭了我的自我。
- 我可以使用它们,但选择一个怎么样。这对我来说并不容易。
例如我喜欢(Nemerle)
match(STT)
| 1 with st= "Summ"
| 2 with st= "AVG" =>
$"$st : $(summbycol(counter,STT))"
远不止于此 (F#)
let (|Let|) v e = (v, e)
match stt with
| Let "Summ" (st, 1)
| Let "AVG" (st, 2) -> srintf "%s ..." st
F# :
["A"; "B"] |> List.iter (fun s -> printfn "%d" s.Length)
内默尔:
["A", "B"].Iter(x => printf("%d", x.Length))
F#(希望这里没有弄错):
let type X =
let mytable a = ""
let mytable b = ""
new(A, B) = {
a <- A
b <- B }
member X.A
with get = a
member X.B
with get = a
内默尔:
[Record]
class X
public A : string { get; }
public B : string { get; }
C# :
class X
{
private readonly string _a;
public string A { get { return _a; } }
private readonly string _b;
public string B { get { return _b; } }
public X(string a, string b)
{
_a = a;
_b = b;
}
}
这是我已经无法转换为 F# 的 nemerle 代码(所以我只学习它)......
abstract class ABase
abstract public A : string { get; }
interface IB
B : string { get; }
[Record]
class My : ABase, IB
public override A : string { get; }
public virtual B : string { get; }
与 C# 的比较:
abstract class ABase
{
abstract public string A { get; }
}
interface IB
{
string B { get; }
}
class My : ABase, IB
{
private readonly string _a;
public override A : string { get { return _a; } }
private readonly string _b;
public virtual B : string { get { return _b; } }
public My(string a, string b)
{
_a = a;
_b = b;
}
}
显然,Nemerle 代码更易于支持且更具可读性。
@Brian所以这就是我要问的原因,如果你发现我做错了,告诉我是否真的可以让 F#、C# 更轻松,因为我不确定其他方法可以清楚地做到这一点。