Prothon在Vers 0.1.0中获得Major Facelift [Prothon] [英] Prothon gets Major Facelift in Vers 0.1.0 [Prothon]

查看:115
本文介绍了Prothon在Vers 0.1.0中获得Major Facelift [Prothon]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为这里有一个新的Prothon版本值得一提。

Prothon版本0.1.0已经变得几乎无法识别与此处讨论的

相比之前。例如:Perl-like和Perl-like。符号消失

和自我关键字返回,替换期间。 Prothon已经获得了更多的类似python,更简单,更强大,同时也是如此。


有一个新的教程,涵盖了Prothon完全没有假设任何关于Python或任何其他语言的知识。 Prothon / Python差异

页面现在链接到本教程的相关部分。

参见 http://prothon.org


其中一些差异是:


本地和全局变量已经消失,取而代之的是一个简单的方案,允许你从一个块或函数内部访问任何本地或外部变量

范围的名称。你也可以修改

当前范围之外的任何现有变量,只需在前面加上外部即可。变量名称,如

" outer.x = 1"。你甚至可以这样做外部访问。当变量在

时,一个已经退出运行的函数,给你闭包。不需要

特殊语法。


有一种新的强大的自我绑定方法语法,可以给你

明确指定自我的能力使用

" obj.func {self}(args)"绑定到函数调用。这样可以在不影响函数调用的简单性的情况下使用消息传递的全部功能。这个强大的

和一般方案也解决了在有
时调用方法的问题,没有类来定义方法是什么。智能默认值

for {self}允许大多数方法调用是直观且简单的形式

obj.call()。


with;关键字现在只是创建一个新的本地范围而不是另一个

self这之前很混乱。所以自我现在是方法中实例对象的简单含义,就像在Python中一样。


有一个新的对象关键字的作用几乎与

类相同。关键字,还可以作为一般对象创建和
初始化语句。它结合了对象创建和with

语句。

There is a new release of Prothon that I think is worth mentioning here.
Prothon version 0.1.0 has changed almost beyond recognition compared to what
was discussed here before. For example: the "Perl-like" symbols are gone
and the "self" keyword is back, replacing the period. Prothon has gotten
more "python-like", simpler, and more powerful, all at the same time.

There is a new tutorial that covers Prothon completely without assuming any
knowledge of Python or any other language. The Prothon/Python differences
page now has links to the relevant section of this tutorial.
See http://prothon.org.

Some of these differences are:

Locals and globals are gone and replaced by a simple scheme that allows you
to access any local or external variable from inside a block or function
scope by name. You may also modify any existing variable outside of the
current scope by simply prepending "outer" to the variable name as in
"outer.x = 1". You can even do this "outer access" when the variable is in
a function that has quit running, giving you "closures" with no need for a
special syntax.

There is a new powerful self-binding method syntax that gives you the
ability to explicitly specify the "self" to bind to a function call with
"obj.func{self}(args)". This allows the full power of message-passing to be
used without compromising the simplicity of function calling. This powerful
and general scheme also solves the problem of calling methods when there is
no such thing as a class to define what a method is. Intelligent defaults
for {self} allow most method calls to be the intuiitive and simple form
obj.call().

The "with" keyword now just creates a new local scope instead of another
"self" which was so confusing before. So "self" is now the simple meaning
of the instance object inside a method as it is in Python.

There is a new "object" keyword which works almost identically to the
"class" keyword, yet also works as a general object creation and
initialization statement. It combines object creation and the "with"
statement.

推荐答案

有一件事可能会吸引我从Python到Prothon是否有适当的私人方法 - 即不仅仅是__myDef

的名称,可以使用_myClass__myDef覆盖(作为翻译)

确实如此。


在C ++旅作为OO语言认真对待之前需要进行适当的封装,哦和机器码编译器

;-)
One thing that might attract me from Python to Prothon is if it had
proper private medthods - i.e. not just name mangling like __myDef
which can be overridden using _myClass__myDef (as the interpreter
does).

Proper encapsulation is needed before the C++ brigade will take
P[y/ro]thon seriously as an OO language, oh and a machinecode compiler
;-)


simo写道:
可能吸引我从Python到Prothon的一件事是if它有适当的私人方法 - 即不仅仅是像__myDef
这样的名称可以使用_myClass__myDef覆盖(如解释器那样)。

需要正确的封装在C ++旅之前认真对待P [y / ro]作为OO语言,哦和机器码编译器
; - )
One thing that might attract me from Python to Prothon is if it had
proper private medthods - i.e. not just name mangling like __myDef
which can be overridden using _myClass__myDef (as the interpreter
does).

Proper encapsulation is needed before the C++ brigade will take
P[y/ro]thon seriously as an OO language, oh and a machinecode compiler
;-)



PROthon应该实现{...}作为可选的块乞讨和结束标记。


#原始的PROthon代码(使用缩进)

def abc(_x):

if _x ...:

do_1()

do_2()

do_3()

可以成为


#!/ usr / bin / pROthon

#pragma(C_STYLE_BLOCK = 1)#< - 在此文件/模块范围内有效


def abc(_x):

{

if _x ...:

{

do_1()

do_2()

}

do_3()

}


------------- ---------------------------


缺乏阶级类型和直接创建和使用对象非常方便基于原型的编程。 (那是'PROthon)


谁说OO编程必须有班级类型?


// moma

http:/www.futuredesktop.org


PROthon should implement {...} as optional block-beg and end marks.

# Original PROthon code (uses indentation)
def abc(_x):
if _x ...:
do_1()
do_2()
do_3()
Could become

#!/usr/bin/pROthon
#pragma(C_STYLE_BLOCK=1) # <- Valid within this file/module scope

def abc(_x):
{
if _x ...:
{
do_1()
do_2()
}
do_3()
}

----------------------------------------

The lack of "class" type and direct creation and use of objects is very
handy for "Prototype-based Programming" (that''s PROthon)

Who said OO-programming must have a class type ?

// moma
http:/www.futuredesktop.org


On Sun,2004-05-23 at 21:46 +0000,Neil Hodgson写道:
On Sun, 2004-05-23 at 21:46 +0000, Neil Hodgson wrote:
gabor:
gabor:
嗯...我明白你可以扔掉const,
但是怎么样......

C类
{
私人x;
};
技术1:

D类{
公众:
int x; < c c;
(reinterpret_cast< D *>(& c)) - > x = 1;

技术2 :

#define private public
#include< C_definition.h>
#undef private

C c;
cx = 1 ;
hmmm...i understand that you can cast away const,
but what about...

class C
{
private x;
};
Technique 1:

class D {
public:
int x;
};

C c;
(reinterpret_cast<D*>(&c))->x = 1;

Technique 2:

#define private public
#include <C_definition.h>
#undef private

C c;
c.x = 1;



谢谢......非常有趣。

在这两个中很明显,封装规则正在被打破,这正是与某人使用受损的名字相同的情况我蟒蛇我在生产代码中使用了技术2,其中无法更改库
并且需要访问私有方法。


thanks...very interesting.
In both of these it is obvious that the encapsulation rules are being
broken which is exactly the same situation as when someone uses the mangled
name in Python. I have used technique 2 in production code where a library
could not be altered and access to private methods was required.




看...我不是在python中寻求一种方式来完全限制

访问一个变量...我暗示就够了......现在......如果我知道正确

这意味着我必须使用

" _"前缀我想要私有变量...这个限制对我来说已经足够了。我的问题是

语法。我讨厌任何甚至远程类似perl / hungarian

表示法的东西。为什么我不能以某种方式创建静态方法....


class C:

def __init __(self):

self.lenght = 5

self.lenght = private(self.length)


或类似内容。

重点是:

i只想写变量是私有的一次......

i不想处理我的_prefixed变量整个代码...


这当然是imho


gabor



look...i am not asking for a way in python to COMPLETELY RESTRICT the
access to a variable... i hint is enough... now...if i know correctly
that means that i have to prefix my wanto-to-be-private variables with a
"_"... that restriction would be enough for me. my problem is with the
syntax. i HATE anything that even remotely resembles perl/hungarian
notation. why cannot i do it somehow as we create static-methods ....

class C:
def __init__(self):
self.lenght = 5
self.lenght =private(self.length)

or something like it.

the point is:
i only want to WRITE that the variable is private once...
i don''t want to deal with _prefixed variables in my whole code...

this is imho of course

gabor


这篇关于Prothon在Vers 0.1.0中获得Major Facelift [Prothon]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆