为csharp提出新的解决方案 [英] Propose new feuture for csharp
问题描述
嗨!
不知道这个论坛是否有人读过MS团队的人。我想是的,所以
提出我非常需要的新语言未来:-)
我认为在C#中使用像macros这样的东西会很好,但更多
强大。以下是示例:
//代码框<br />
公共代码框MyCodeFrame
{
初始化
{
DataBase db = new DataBase();
尝试
{
db.StartTransaction();
}
定稿
{
db.Commit() ;
}
catch
{
db.Rollback();
抛出;
}
}
}
//在某些方法中使用此代码框架:
....
usecodeframe(MyCodeFrame)
{
ob.RunCommand(" INSERT INTO ... ...);
...
}
....
由于编译我想要而不是
usecodeframe(MyCodeFrame)
子句:
....
DataBase db = new DataBase();
try
{
db.StartTransaction( );
ob.RunCommand(" INSERT INTO ...");
...
db.Commit();
}
catch
{
db.Rollback();
throw;
}
....
我认为这对许多人来说都很有用......来自MS的Maby某人b
团队可以提议MS在C#4.0中实现这个未来: - )
为什么不将它包装在一个物体中?
sasha写道:
嗨!
不知道这个论坛是否有人读过MS团队的人。我想是的,所以
提出我非常需要的新语言未来:-)
我认为在C#中使用像macros这样的东西会很好,但更多
强大。以下是示例:
//代码框<br />
公共代码框MyCodeFrame
{
初始化
{
DataBase db = new DataBase();
尝试
{
db.StartTransaction();
}
定稿
{
db.Commit() ;
}
catch
{
db.Rollback();
抛出;
}
}
}
//在某些方法中使用此代码框架:
...
usecodeframe(MyCodeFrame)
{
ob.RunCommand(" INSERT INTO。 ..);
...
}
...
As我想要编译的结果而不是
usecodeframe(MyCodeFrame)
子句:
...
DataBase db = new DataBase();
尝试
{
db.StartTransaction();
ob.RunCommand(" INSERT INTO ...");
...
db.Commit();
}
catch
{
db.Rollback ();
throw;
}
...
我认为这可以是对很多人有用...... Maby某人来自MS
团队可以提议MS在C#4.0中实现这个未来:-)
< blockquote>大多数人认为纯文本宏是一件坏事。 MS在DotNet框架中包含了许多代码生成库,
以及构建codegen工具的方法。宏只能真正干净利落地工作,比如Lisp这样的同色语言 - 过度依赖基于文本的宏可以使得b $ b导致编译时间过长(如大量使用C ++所见<
模板)和糟糕的设计时错误验证。
MS已经明确了他们的方法:如果类似宏的功能是
需要,它应该使用代码生成完成。
但如果你真的想要宏,你可以尝试Nemerle - 它是DotNet
编程语言设计看起来类似于C#,但有宏,
类型推理和内置函数式编程。
老实说,如果MS有更好的表现在
C#中的元编程系统,他们会在一开始就实现它并使用它的模型实现大部分
语言而不是黑客攻击这么多的功能
之后(Common Lisp这样做 - Lisp中的整个OOP系统是一组
宏)。
我的大期望功能 for 3.0对于
不可变对象有更好的语言支持 - 现在是一般的复制对象,同时更改
某些字段实现起来非常繁琐,而且对于不可变结构来说这是一个很常见的习惯。
sasha写道:
嗨!
不知道这个论坛是否有人读过MS团队的人。我想是的,所以
提出我非常需要的新语言未来:-)
我认为在C#中使用像macros这样的东西会很好,但更多
强大。以下是示例:
//代码框<br />
公共代码框MyCodeFrame
{
初始化
{
DataBase db = new DataBase();
尝试
{
db.StartTransaction();
}
定稿
{
db.Commit() ;
}
catch
{
db.Rollback();
抛出;
}
}
}
//在某些方法中使用此代码框架:
...
usecodeframe(MyCodeFrame)
{
ob.RunCommand(" INSERT INTO。 ..);
...
}
...
As我想要编译的结果而不是
usecodeframe(MyCodeFrame)
子句:
...
DataBase db = new DataBase();
尝试
{
db.StartTransaction();
ob.RunCommand(" INSERT INTO ...");
...
db.Commit();
}
catch
{
db.Rollback ();
throw;
}
...
我认为这可以是对很多人有用...... Maby某人来自MS
团队可以提议MS在C#4.0中实现这个未来:-)
< blockquote>大多数人认为纯文本宏是坏事。
但我不建议使用宏!我建议使用LANGUAGE构建!!!
我正在编写libruary,以便在事务环境中轻松使用DB ...
所以我有其他的问题。我有Dispose方法的课。我在使用中创建了这个类的对象
,例如:
using(DBWrapper db = DBManager.CreateDBWrapper())
$
db.ExecuteNonQuery(" INSERT INTO ..)
//例如这里是zere by zere exception
int i = 100/0;
db.ExecuteNonQuery(" INSERT INTO ..")
}
现在在DBWrapper.Dispose()我应该知道我是否可以COMMIT交易或
必须ROLLBACK它。
所以我需要know id Dispose方法如果存在未加异常的异常。
我该怎么做?
PS请不要写关于try / catch: - )
Hi!
Don''t know if this forum read somebody from MS team. I suppose yes, so
propose new language future wich i need very much :-)
I think it would be nice to have in C# something like macros, but more
powerfull. Here is example:
// code frame
public codeframe MyCodeFrame
{
initialization
{
DataBase db = new DataBase();
try
{
db.StartTransaction();
}
finalization
{
db.Commit();
}
catch
{
db.Rollback();
throw;
}
}
}
// use this code frame inside some method:
....
usecodeframe(MyCodeFrame)
{
ob.RunCommand("INSERT INTO ...");
...
}
....
As a result of compillation i want to se instead of
usecodeframe(MyCodeFrame)
clause:
....
DataBase db = new DataBase();
try
{
db.StartTransaction();
ob.RunCommand("INSERT INTO ...");
...
db.Commit();
}
catch
{
db.Rollback();
throw;
}
....
I think this can be usefull for many people... Maby someone from MS
team can propose MS to implement this future in C# 4.0 :-)
Why not just wrap that up in an object?
sasha wrote:Hi!
Don''t know if this forum read somebody from MS team. I suppose yes, so
propose new language future wich i need very much :-)
I think it would be nice to have in C# something like macros, but more
powerfull. Here is example:
// code frame
public codeframe MyCodeFrame
{
initialization
{
DataBase db = new DataBase();
try
{
db.StartTransaction();
}
finalization
{
db.Commit();
}
catch
{
db.Rollback();
throw;
}
}
}
// use this code frame inside some method:
...
usecodeframe(MyCodeFrame)
{
ob.RunCommand("INSERT INTO ...");
...
}
...
As a result of compillation i want to se instead of
usecodeframe(MyCodeFrame)
clause:
...
DataBase db = new DataBase();
try
{
db.StartTransaction();
ob.RunCommand("INSERT INTO ...");
...
db.Commit();
}
catch
{
db.Rollback();
throw;
}
...
I think this can be usefull for many people... Maby someone from MS
team can propose MS to implement this future in C# 4.0 :-)
Most people consider pure-textual macros to be a Bad Thing. MS has
included numerous code-generation libraries in the DotNet framework,
and ways to build codegen tools. Macros only really work cleanly in
homoiconic languages like Lisp - overreliance on text-based macros can
result in freakishly long compile-times (as seen in heavy use of C++
Templates) and poor design-time error validation.
MS has made their approach clear: if macro-like functionality is
needed, it should be done using code generation.
But if you really want macros, you can try Nemerle - it''s DotNet
programming language designed to look similar to C# but with macros,
type-inference, and functional programming built-in.
Honestly, if MS was going to have a better metaprogramming system in
C#, they would''ve implemented it at the start and implemented much of
the language using it''s model rather than hacking so many features in
later (Common Lisp does this - the whole OOP system in Lisp is a set of
macros).
My big "desired feature" for 3.0 is better linguistic support for
immutable objects - right now a general "copy object while changing
certain fields" is incredibly tedious to implement, and it is a very
common idiom for immutable structs.
sasha wrote:Hi!
Don''t know if this forum read somebody from MS team. I suppose yes, so
propose new language future wich i need very much :-)
I think it would be nice to have in C# something like macros, but more
powerfull. Here is example:
// code frame
public codeframe MyCodeFrame
{
initialization
{
DataBase db = new DataBase();
try
{
db.StartTransaction();
}
finalization
{
db.Commit();
}
catch
{
db.Rollback();
throw;
}
}
}
// use this code frame inside some method:
...
usecodeframe(MyCodeFrame)
{
ob.RunCommand("INSERT INTO ...");
...
}
...
As a result of compillation i want to se instead of
usecodeframe(MyCodeFrame)
clause:
...
DataBase db = new DataBase();
try
{
db.StartTransaction();
ob.RunCommand("INSERT INTO ...");
...
db.Commit();
}
catch
{
db.Rollback();
throw;
}
...
I think this can be usefull for many people... Maby someone from MS
team can propose MS to implement this future in C# 4.0 :-)
Most people consider pure-textual macros to be a Bad Thing.
But i do not propose macros! I propose LANGUAGE construction!!!
I''m writing libruary for easy working with DB in transaction context...
So i have other querstion. I have class with Dispose method. I create
objects of this class inside of using, for example:
using(DBWrapper db = DBManager.CreateDBWrapper())
{
db.ExecuteNonQuery("INSERT INTO ..")
// for example here is devision by zere exception
int i = 100 / 0;
db.ExecuteNonQuery("INSERT INTO ..")
}
Now in DBWrapper.Dispose() i should know if i can COMMIT transaction or
must ROLLBACK it.
So i need know id Dispose method if exists unhendled exception or not.
How can i do this?
PS Please don''t write about try/catch :-)
这篇关于为csharp提出新的解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!