ANN: Tao Scripting Language 0.8.5 beta released!
Dear all, I am glad to announce in this mailing list that the lastest version of a new scripting language has come out. Welcome to try it out. Comments are welcome. Suggestions are appreciated. === Here are some details: === Design Goals: 1. Simple and efficient. 2. Integrate nice features of other languages whenever possible. Implementation language: C++ with STL. Designer: Fu Limin Email: fu [dot] limin [dot] tao [at] gmail.com Key features have been supported: 1. Dynamic-typing variables, supporting complex data structures such as array/list, hash/dictionary and matrix etc. 2. Object-oriented programming ( multi-inheritance not supported yet ). 3. Basic string regular expression matching. 4. Automatic garbage collection capable of collecting cyclically referenced objects. 5. Numeric data types: complex number and matrix, and their basic operations. 6. Convenient namespacing and dynamic creation of subroutines and classes. 7. Dynamic loading of C/C++ modules ( not complete, but enough for playing with it ^_^ ). 8. An embedded tiny XML parser. ToBeDone: More string operations, multi-inheritance of classes, improvements on C/C++ module loading, more on regular expression matching and possible optimizations etc. Documentation: http://taoscript.sourceforge.net/brief_tao.php Sample scripts: http://taoscript.sourceforge.net/sample.php Download: http://taoscript.sourceforge.net/downloads.php Best regards, Limin -- Homepage for Tao Language: http://taoscript.sourceforge.net Tao Language project at sourceforge.net: http://sourceforge.net/projects/taoscript -- http://mail.python.org/mailman/listinfo/python-list
Re: Tao Scripting Language 0.8.5 beta released!
Dear Claudio,
Thank you for your kind testing, suggestions and encourages.
I'm glad that you like it.
For that problem in the Lexer, it can be corrected without increasing
the size. I will do it soon.
Best regards,
Limin
On Thu, 27 Jan 2005 15:32:13 -, Claudio Grondi
<[EMAIL PROTECTED]> wrote:
> Dear Limin,
>
> Tao Script with its 300 KByte of code is so small,
> that one just must love it forgiving all its baby
> troubles.
>
> After changes (see below) to the code in taoModule.cpp
> necessary because my compiler claimed repeated definition
> of 'ref' e.g. in the section:
> if(TaoReference *ref2a=inNameSpace->findDataShared(name) ){
> myData[name]=ref2a;
> outNameSpace->nsData[name]=ref2a;
> }else{
> TaoShareRefer*ref2b=new TaoShareRefer();
> myData[name]=ref2b;
> outNameSpace->nsDataShared[name]=ref2b;
> outNameSpace->nsData[name]=ref2b;
> }
> I was able to compile the code with
> Microsoft Visual C++ .NET 2003 on W2K
> (create an empty .NET project, add all source
> code files, compile and be happy :-)
>
> Trying the examples provided on the
> homesite of Tao Script which run ok as they
> are, I found, that print("### \n") failes due to
> the way the Lexer works beeing not able to
> proper handle string literals.
> One just can't probably use any of "#'" "//" "/*"
> in strings because the lexer strips the
> comments before it analyses the source
> to handle content of the string literals.
>
> Hope this comment helps you to continue
> the well done work on it.
> I had fun with it because of its size, so
> from my point of view please try to
> keep the project as small as possible, so
> that it remains easy to check out the entire
> code.
> Maybe it is even a good idea to keep
> the problem with the strings as a "feature"
> in order to keep the Lexer as simple as
> possible?
>
> Best regards
>
> Claudio
>
> "Limin Fu" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
> news:[EMAIL PROTECTED]
> > Dear all,
> >
> > I am glad to announce in this mailing list that the lastest version
> > of a new scripting language has come out.
> >
> > Welcome to try it out.
> >
> > Comments are welcome.
> >
> > Suggestions are appreciated.
> >
> > ===
> > Here are some details:
> > ===
> >
> > Design Goals:
> > 1. Simple and efficient.
> > 2. Integrate nice features of other languages whenever possible.
> >
> > Implementation language: C++ with STL.
> >
> > Designer: Fu Limin
> > Email: fu [dot] limin [dot] tao [at] gmail.com
> >
> > Key features have been supported:
> >
> > 1. Dynamic-typing variables, supporting complex data structures
> >such as array/list, hash/dictionary and matrix etc.
> >
> > 2. Object-oriented programming ( multi-inheritance not supported
> >yet ).
> >
> > 3. Basic string regular expression matching.
> >
> > 4. Automatic garbage collection capable of collecting cyclically
> >referenced objects.
> >
> > 5. Numeric data types: complex number and matrix, and their basic
> >operations.
> >
> > 6. Convenient namespacing and dynamic creation of subroutines and
> >classes.
> >
> > 7. Dynamic loading of C/C++ modules ( not complete, but enough for
> >playing with it ^_^ ).
> >
> > 8. An embedded tiny XML parser.
> >
> > ToBeDone:
> > More string operations, multi-inheritance of classes, improvements
> > on C/C++ module loading, more on regular expression matching and
> > possible optimizations etc.
> >
> > Documentation:
> >
> > http://taoscript.sourceforge.net/brief_tao.php
> >
> > Sample scripts:
> >
> > http://taoscript.sourceforge.net/sample.php
> >
> > Download:
> > http://taoscript.sourceforge.net/downloads.php
> >
> > Best regards,
> >
> > Limin
> >
> > --
> > Homepage for Tao Language:
> > http://taoscript.sourceforge.net
> >
> > Tao Language project at sourceforge.net:
> > http://sourceforge.net/projects/taoscript
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
Homepage for Tao Language:
http://taoscript.sourceforge.net
Tao Language project at sourceforge.net:
http://sourceforge.net/projects/taoscript
--
http://mail.python.org/mailman/listinfo/python-list
Re: ANN: Tao Scripting Language 0.8.5 beta released!
> Since you chose to announce it in this mailing list/newsgroup, may I
> suggest that a comparison with Python is in order?
>
To make a reasonable comparison with Python, I need to spend more time
to investigate into python, since so far I only know some basic things
in Python :-). But I can ensure that Tao is very different from
Python, and it will be more different in the future.
> Since it is a new scripting language, I'm not suggesting a language war,
> but rather a simple statement of how Tao differs from Python, and what
> "itch" you were trying to scratch when you designed your new language.
Well, I started to design this language, because I work on
bioinformatics and I hardly found any language that really satisfied
me. I found that, a language with simple syntax, convenient text
processing functionality, powerful numeric computation capability, and
simple C/C++ interfaces would be very useful in this field.
Perl is got out immediately due to its complicated syntax and many
possible traps(though there are still many people using it in this
field, I think it is due to historical reasons). Though Python is
great in many aspects, its syntax is also something I don't really
like, and I think its interface to C/C++ is not simple enough. R
language is not well designed according to me, though it's more
popularly used in bioinformatic than Python. So I decided to design a
new language. Though that goal is not reached yet, it is not
unreachable either.
> Basically, how does your design philosophy differ from that of Guido?
I think I agree much of the design philosophy of Guido. But it is just
a kind of guide line, it doesn't imply anything about the structure of
the language and the interpreter. So the same philosophy can come out
completely different language.
> Where did you go left when Python went right?
I will only point out a few such places.
1. Tao use uniform parenthesis symbol for both list/array and
hash/dictionary, that is []. While in Python, [] is used for list, and
{} is used for dictionary.
2. In Tao, there is no "self" argument in class methods as in Python.
And the class syntax of Tao is more similar to that of C++.
3. Some Matlab features regarding numeric types, multi returned
values in functions and multi assignment etc. are integrated into Tao.
4. Tao provides a very convenient way of declaring array/list which,
to the best of my knowledge, is not presented in any other language.
That is,
a=[10][5] : value/arith/function;
which will create a 10x5 array with elements resulted from evaluation
of the right side of ":".
Best regards,
Limin
--
Homepage for Tao Language:
http://taoscript.sourceforge.net
Tao Language project at sourceforge.net:
http://sourceforge.net/projects/taoscript
--
http://mail.python.org/mailman/listinfo/python-list
Re: ANN: Tao Scripting Language 0.8.5 beta released!
I only looked at languages which are more often used in bioinformatics, at that time I didn't heard about Lua. I knew it about 2 or 3 months after I began to implement Tao. For Io, this is my first time to hear about it :) Cheers, Limin On Thu, 27 Jan 2005 23:02:45 +0100, PA <[EMAIL PROTECTED]> wrote: > > On Jan 27, 2005, at 22:54, Limin Fu wrote: > > > I found that, a language with simple syntax, convenient text > > processing functionality, powerful numeric computation capability, and > > simple C/C++ interfaces would be very useful > > You bet. > > Have you looked at Lua? > > http://www.lua.org/about.html > > Or perhaps Io? > > http://www.iolanguage.com/About/ > > Cheers > > -- > PA, Onnay Equitursay > http://alt.textdrive.com/ > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Homepage for Tao Language: http://taoscript.sourceforge.net Tao Language project at sourceforge.net: http://sourceforge.net/projects/taoscript -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: Tao Scripting Language 0.8.5 beta released!
I should admit I only read a little bit very simple introductions of Lua, so I can't answer you question exactly now. Maybe you can found the answer by yourself by spending some minutes to read the brief documentation of Tao. Depending how much time I have, probably I will make a comparison between Tao and other languages, and make it available in the website of Tao. But it will not be soon. Cheers On Thu, 27 Jan 2005 23:47:27 +0100, PA <[EMAIL PROTECTED]> wrote: > > On Jan 27, 2005, at 23:42, Limin Fu wrote: > > > at that time I didn't heard about Lua. I knew it about > > 2 or 3 months after I began to implement Tao. > > So, compared to Lua for example, what does Tao brings to the table that > you found worthwhile? > > Cheers > > -- > PA, Onnay Equitursay > http://alt.textdrive.com/ > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Homepage for Tao Language: http://taoscript.sourceforge.net Tao Language project at sourceforge.net: http://sourceforge.net/projects/taoscript -- http://mail.python.org/mailman/listinfo/python-list
How is Python designed?
Hello, Is there any technical description on internet of how python is designed? Or can somebody give a short description about this? I'm just curious. Thanks in advance, Limin __ Do you Yahoo!? Yahoo! Mail - You care about security. So do we. http://promotions.yahoo.com/new_mail -- http://mail.python.org/mailman/listinfo/python-list
Re: How is Python designed?
--- Timo Virkkala <[EMAIL PROTECTED]> wrote: > > Do you mean the structure and design of the > language, or the process of > designing the language? I mean the structure and design of the language. Sorry for the umbiguous question. > > Well, in either case, you'll probably find your > answer at http://www.python.org > > Take a look at the Docs -> Language Reference and > PEP sections. I will have a look at there. Thanks. Limin __ Do you Yahoo!? Dress up your holiday email, Hollywood style. Learn more. http://celebrity.mail.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
Re: How is Python designed?
To clarify, I mean the internal structure and design of python interpreter. Any hint? Thanks. Regards, Limin __ Do you Yahoo!? Yahoo! Mail - 250MB free storage. Do more. Manage less. http://info.mail.yahoo.com/mail_250 -- http://mail.python.org/mailman/listinfo/python-list
Re: How is Python designed?
Thanks a lot for the explanations. So CPython used more or less the standard technique to implement the interpreter. Are there any other interpretation techniques? I guess many. But I'm quite new in this field and I couldn't find good references on internet about this. If there is anybody has such references, please send me some if you don't mind. I would be appreciative very much. Best, Limin --- Terry Reedy <[EMAIL PROTECTED]> wrote: > > "Limin Fu" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > To clarify, I mean the internal structure and > design > > of python interpreter. Any hint? Thanks. > > Ah... The interpreters (plural) are a separate issue > from the language > itself (a Python program is a list of Python > statements, etc). We'll > presume that you specifically mean the CPython > interpreter, as opposed to > Jython, Viper, Ironman, PyPy, Parrot, or the human > brain. For CPython: > > human or other source code generator ==> Python > source code > > CPython compile phase: > lexer ==> tokens > parser ==> ast tree > byte code generator ==> byte codes for Python > virtual machine > (see the Lib Ref chapter on the dis module for VM > commands) > > CPython runtime phase: > code evaluator ==> computations >(see source file ceval.c for the link between > byte codes and C > functions) > > CPython is currently both the reference > implementation and the most > commonly used implementation. Both facts could > change in the future, > possibly even with divergence between the two roles. > Since Python is meant > to be a practical computer language as well as an > abstract algorithm > language (for humans), a reference implementation is > needed to show that > proposed language features can be sensibly > implemented. > > Terry J. Reedy > > > > -- > http://mail.python.org/mailman/listinfo/python-list > __ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
Re: How is Python designed?
> If you want cutting-edge, mind twisting stuff, look > into > Psyco extension (Armin Rigo, 1.3 just announced > here) > Stackless extension (Christian Tismer) > PyPy (new interpreter written in Python, several > people, has EU funding) That would be interesting. However I am designing and implementing another interpreter. The techniques I'm using seems to be different from most of current interpreters (I hope so, I'm not very sure, that why I come to ask questions about interpretation techniques). The programming language is C++. The basic idea of this technique is to create a class to represent each type of script phrase(that's the term I used in the program, it's just a piece of code for particular task such assignment,logical/loop control,function call, whatever). In the phase of compiling, phrase instances of such classed are made, and in the execution phase, starting from the first, each phrase instance is executed and jump to the next phrase instance for subsequential execution, like a finite state automa I would say. Currently the interpretation efficiency is comparable to most popular interpreters. For more information, please have a look at: http://yuan-language.sourceforge.net/ Honest saying, it has just come out for a few monthes, it's not well tested and there is much things to be improved. So don't be surprised if some bugs come out when you run it. In this case, please let me known. Cheers, Limin __ Do you Yahoo!? Yahoo! Mail - Easier than ever with enhanced search. Learn more. http://info.mail.yahoo.com/mail_250 -- http://mail.python.org/mailman/listinfo/python-list
Re: How is Python designed?
Hi,
Probably you didn't understand well what I meant or
maybe I didn't express clearly what I meant. So I
think I need to spend more words to make it clear.
First, there is no abstract syntax tree generated for
the whole program, except for arithmetic
expression(even for this, it is slightly different
from what you said, I will come back to this point).
The Yuan (the name of the interpreter I designed)
interpreter first scans the source script, when it see
a pattern, for example "if(a>1)", it generates a
phrase object containing the arithmetic expression and
the ID (it is determined after all phrase objects are
created) of other two phrase objects. This phrase
object has a member method "execute()", whose
execution will return one of the IDs depending on the
value of "a>1". Then the next phrase object with that
ID is executed, and so on. I don't know how is the AST
for a whole program, I think it should be more
complicated than this.
Then about arithmetic expression, indeed, it is
represented as tree. But in Yuan each node contains
all the information it need for evaluation. For
example, the leaves contains either a variable or a
constant value or a function call, and other nodes
contains the operators. So far it is more or less the
same as what you mentioned. But the evaluation is
performed on this tree directly with deep first
search, which is different from the two methods you
mentioned. The first one you mentioned is the same as
my first implementation, which results an unefficient
recursive function call. The second is the standard
way of evaluating arithmetic expressions. I guess I am
not the first one to evaluate arithmetic expression by
deep-first search on the tree (I would be surprised if
I am). Any way it is enough efficient.
Your further comments and discussion are welcome, I'm
not that type who is afraid of negative opinions :)
Any way I will continue to improve that interpreter,
it's an interesting thing for me.
Regards,
Limin
> I'd say that's pretty much standard interpreter
> technique - an expression
> like this:
>
> foo = a + b * c
>
> is translated and reduced to an abstract-syntax-tree
> something like this:
>
> Assignment("foo", BinaryOp("+", Get("a"),
> BinaryOp("*", Get("b"),
> Get("c"
>
> Then on Assignment one can invoke eval(), and get
> the result. Assignment
> will invoke eval on its children, which in turn will
> do that for their
> operands, until something can be computed. The
> result is returned.
>
> By using an emulated stack or register-machine, you
> can flatten that to
> something like this:
>
> push Get("c")
> push Get("b")
> push BinaryOp("*")
> push Get("a")
> push BinaryOp("+")
> pop Assignment("foo")
>
> This is of course very makeshift - but you'll get
> the idea.
>
> This doesn't mean I want to discourage you - on the
> contraire. Developing
> your own language is highly educating, and I
> personally love it when I
> "invent" something and then later find out that
> people much cleverer than
> me did so before - it shows that I went down the
> same paths of thought :)
>
> --
> Regards,
>
> Diez B. Roggisch
> --
> http://mail.python.org/mailman/listinfo/python-list
>
__
Do you Yahoo!?
Read only the mail you want - Yahoo! Mail SpamGuard.
http://promotions.yahoo.com/new_mail
--
http://mail.python.org/mailman/listinfo/python-list
Re: How is Python designed?
Well, you are the first who really want to join to the development of Yuan, I'm quite glad. We can further discuss in detail outside of this python mailing list, since it is not the place for such discussion. Here I just mention a few things here, maybe I can also get some advices from some experienced guys, hopefully. First, I don't doubt your C++ skill, theoretical background and passion for developing a scripting language. BUT YOU SHOULD MAKE SURE IF YUAN IS THE SAME AS WHAT YOUR HAVE THOUGHT. I should point out that, there is no virtual machine in Yuan, you can read some discussion posts I made with others people in this list. I can give more details on Yuan if you want. You may also have a look to the website: http://yuan-language.sourceforge.net/ Though Yuan is not well documented yet, you can get some impression of it from that website. Second, it is about licensing. Yuan will always be available under GPL (as long as it will survive). But I also wanted it can be used for commercial applications. Now what I'm thinking and planing to do is, to add one or two exceptions to GPL, so that Yuan can be used for certain types of commercial application without charging a fee, but COMPLETE integration (I mean when the communication between Yuan and other applications is beyond certain predefined interfaces) of Yuan with no GPLed applications would require a license fee(of course part of it will be share by the developers proportional to their contribution and the other part will be used to promote Yuan). The main reason I want to do so is, I want to setup a more or less stable(maybe not, I want to try it out) financial source for the development of Yuan. I am not sure if this licensing model will work for the interpreter of a scripting language :). Anyone tried it? In the case of scripting language, licensing is just a matter of strategy to enlarge the usage of itself (maybe I'm wrong). The reason I don't adopt the same strategy of python or perl etc. is that, I'm really not sure how many companies are willing to support such project voluntarily. Maybe somebody here can give me a hint. Anyway, anyone is welcome to join the develop of Yuan. If you don't agree with me on some of the above points, please tell me of your opinions, and I will consider them carefully. Thanks in advance. Best regards, Limin --- Robert <[EMAIL PROTECTED]> wrote: > Sorry for my interrupting the discussion : ). I am > a graduate student > in a chinese university, and i am very interested > in the Yuan > language. I'd like to join in the development of > Yuan and do some work > for this language. BTW, i like this word, "Yuan" : ) > > I have 3 or 4 years experience in C++, and i have > strong programming > skills about C++(at least in my opinion :) ) . I am > interested in the > compiling technology and virtual machine technology. > And i am reading > the C/C++> written by > Bill Blunden now. I had the thought of starting an > open source project > which contains a virtual machine and a scripting > language a few days > ago, just like a very simple python. Well, i know it > is very difficult, > but it is my dream : ). Luckly i found "Yuan" here. > So it is my > pleasure if i can become a member of "Yuan" :) > > Waiting for your reply. :) > > Best regards. > > > Ru Chen > > -- > http://mail.python.org/mailman/listinfo/python-list > __ Do you Yahoo!? The all-new My Yahoo! - What will yours do? http://my.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
Re: How is Python designed?
Hi,
> Ok, thats clearer. This whole thing sounds familiar
> - the technique you
> describe seems to resemble continuation passing
> style. For a brief
> discussion read here:
>
>
http://www.ps.uni-sb.de/~duchier/python/continuations.html
>
> Python has a continuation-based interpreter
> implementation - its called
> "stackless python". Google for it. It certainly is
> interesting.
That's interesting. I heared of stackless pyton a few
days ago, I will have a more careful look at it.
> And I don't see that the ast is more complicated, at
> least implementation
> wise - in fact, your method requires more analysis
> as for each statement
> its pollible successors have to be computed and made
> known to it - where an
> ast node only knows about its children that more or
> less directly stem from
> the syntax analysis.
Not really. You think in this way, maybe because you
know more about AST and less about that technique I
mentioned. I thinked in the opposite
way because I know different things better.
Hehe.
> I have to admit that I don't know if
> continuation-based evaluation has
> inherent performance-gains. The only thing I can
> think of is that you don't
> need a stackframe in some cases as tail-recursion -
> useful, but not so
> common that one would expect significant performance
> gains there. But as I
> said - I'm not on sure ground here.
I'm not sure either. Certainly it depends very much in
the implementation. If anybody want, we can make some
tests to check. I don't know if it's important,
because it seems people dosen't really care about the
efficiency of an interpreter (as long as it is not
really really too slow).
> Can you elaborate on what you consider beeing an
> unefficient recursive call
> and where there is a difference between your method
> of evaluation and the
> ast-evaluation I mentioned? After all, the
> ast-evaluation is a postorder
> traversal which has the same complexity of a depth
> first search - the only
> difference beeing the latter one using a fifo, the
> forme a lifo for
> managing the list of untraversed nodes. I don't see
> any difference here.
Sorry maybe I didn't understand that part correctly
and took grant that it would be implemented in
recursive way. I just wondered if the following can be
extended for arbitrary length arithmetic expressions:
Assignment("foo", BinaryOp("+", Get("a"),
BinaryOp("*", Get("b"), Get("c"
> I don't have negative opinions about yuan and by no
> meants want to
> discourage you developing it. Its a nice project.
>
If I upseted you or anybody here by un-properly used
words, please forgive me. I always feel my english
must be improved :)
Best regards,
Limin
__
Do you Yahoo!?
Yahoo! Mail - Easier than ever with enhanced search. Learn more.
http://info.mail.yahoo.com/mail_250
--
http://mail.python.org/mailman/listinfo/python-list
Re: How is Python designed?
> I'm > > not that type who is afraid of negative opinions > :) In fact, I was trying to say it in joking way. Unfortunately, it is not obvious due to my poor english! Limin __ Do you Yahoo!? Yahoo! Mail - now with 250MB free storage. Learn more. http://info.mail.yahoo.com/mail_250 -- http://mail.python.org/mailman/listinfo/python-list
Re: How is Python designed?
Hi,
> So I guess you don't use classic parser techniques
> then?
You are right. The Yuan interpreter scans the tokens
resulted from lexical analysis and matches them to the
syntax patterns. There are 3 basic patterns defined in
Yuan: arithmetic "a*b+c", chain (as I called it)
"objs[i]->func()" and regular expression "/\d*[abc]/",
each of which is represented by a class. And the other
patterns are a combination of these 3 basic pattern,
e.g. array enumeration "a=[1,a+1,func()]" etc. There
are functions responsible to parse the token patterns
to phrase objects. After all phrase objects are
generated, logical and loop controls are checked, so
that each phrase object "knows" if it should "step to"
the next phrase object or "jump to" another one when
it is executed. In this technique, indeed, checking
patterns is a little complicated. In Yuan this part is
not optimally implemented, somethings have to be
improved or changed.
> I'm still not sure what you mean by "recursive" - to
> me, recursion is the
> act of a function calling itself until some
> condition is met that markes
> the end (or actually begin I think) of the
> recursion, like this:
>
> def fac(n):
> if n == 1:
> return 1
> return n * fac(n-1)
>
> Thats recursion.
I supposed you would have done like:
class node{
...
char oper;
node *left,*right;
void compute();
};
void node::compute()
{
if(left) left->compute();
if(right) right->compute();
if(oper=='+'){
}else if(...){
}
}
This is a kind of recursive evaluation of arithmetic
tree. Now I believe that's not what you have used.
> If you mean by recursion that the top-node is called
> for evaluation which
> then delegates the evaluation to its children -
Ah, yes. That's exactly what I mean.
> well, that's unavoidable -
That's avoidable, using depth first seach.
> but also in both cases. As I mentioned before, the
> only difference I see is
> the order of evaluation - but that is invariant, as
> long as for all
> expression's their respective sub-expressions are
> evaluated beforehand.
It seemed to me that it made much difference in
efficiency so that I reimplemented it by depth-first
search. Maybe because I didn't implement the recursive
evaluation properly :), I will check.
>
> I'm not upset - I feared you were :) And I perceive
Ok, since non of us is upseted, let's forget it :)
Best,
Limin
__
Do you Yahoo!?
Yahoo! Mail - Helps protect you from nasty viruses.
http://promotions.yahoo.com/new_mail
--
http://mail.python.org/mailman/listinfo/python-list
Re: How is Python designed?
Hi,
> why did you choose that technique and not a common
> parser generator? The
Because I didn't know the standard parse technique
when I started to implement Yuan :)
> kind of parsing you use is somewhat oldfashioned -
> back in the times where
> parsing theory wasn't evolved enough. The
> disadvantage is that without a
> proper theory and a grammar explaining what
> statements are legal and
> meaningful and which not is uneccessary complicated.
>
> Look into the python language reference how use is
> made of a grammar to
> explain language constructs.
I will try to read something about the standard
technique, then dicide what to do with parsing.
Approximately how many lines of C/C++ code, do you
think, are required to implement the standard parser?
>
> > I supposed you would have done like:
> > class node{
> > ...
> > char oper;
> > node *left,*right;
> > void compute();
> > };
> > void node::compute()
> > {
> >if(left) left->compute();
> >if(right) right->compute();
> >if(oper=='+'){
> >
> >}else if(...){
> >
> >}
> > }
> > This is a kind of recursive evaluation of
> arithmetic
> > tree. Now I believe that's not what you have used.
> > Ah, yes. That's exactly what I mean.
>
> That is what I meant. But thats not recursive - the
> compute-calls account
> for the tree-traversal. Nothing recursive there.
Not true. It is not a tranvesal, it is recursive.
Because after compiling, The code I have given becomes
something like:
void compute(node *p)
{
if(p->left) compute(p->left);
if(p->right) compute(p->right);
if(p->oper=='+'){
...
}else if(...){
}
}
You see it is a recursion indeed(if you don't believe,
you can check with other people). And it's unefficient
due to pushing functions into function stack.
>
> > That's avoidable, using depth first seach.
>
> No. Traversal is traversal. A tree of size n needs
> O(n) to be traversed -
> otherwise you missed some nodes.
>
> You can of course cache the results of a tree
> traversal in a list, and call
> the compute method then in a loop:
>
> for node in nodelist:
> ??? = node.compute()
>
> But then you need to explicitely deal with where to
> store the resulting
> values of that computation, so you can access them
> lateron. That will most
> probably eat up the time saved by using that cache.
Temporary results can be saved in class "node" as
member data instead of cache, so there is no extra
cost of time.
Best,
Limin
__
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
--
http://mail.python.org/mailman/listinfo/python-list
Re: How is Python designed?
Of course for such simple expression, that function will not run recursively, but for more complex expressions, it will, as a example: a + b * ( c + ( d - e ) / f )... --- LutherRevisited <[EMAIL PROTECTED]> wrote: > Kinda off subject, just thought I'd add that 0! = 1 > for that recursion example, > since that wasn't considered. Nice post though. > -- > http://mail.python.org/mailman/listinfo/python-list > __ Do you Yahoo!? The all-new My Yahoo! - What will yours do? http://my.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
Re: How is Python designed?
It seems that we focused on different things. I was talking about the example I have given for arithmetic evaluation. And you focused the AST-based evaluation, which, I belive, is different from my example. I also agree that they called the functions for the same number of times, the difference is how they are called. Resursive function is a function called itself. Am I wrong? I'm sure the code in my example is recursive. As I have said, you may show those codes I gave as example to somebody know C++ well to check if it is recursive. Best regards, Limin __ Do you Yahoo!? Read only the mail you want - Yahoo! Mail SpamGuard. http://promotions.yahoo.com/new_mail -- http://mail.python.org/mailman/listinfo/python-list
Re: How is Python designed?
> So maybe you're right in claiming it beeing > recursive. But then, > depth-traversal is recursive, too. No, in the depth-traversal implementation, a function can avoid calling itself (at least in my implementation it's like this). Because you can write seperate functions: a function for depth-traversal (say trav()) and another function for evaluation (say eval()). trav() may call eval(). And eval() NEVER call other functions. For one arithmetic tree, trav() is called once, and eval() is called by trav() at each node. So it is not recursive. > Now apart from that, I still fail to see where your > method of evaluation has > any speed gains. And if you inplement eval() as an "inline" function, there will be no cost for function calls for eval(). In this way it can gain some speeds. Best regards, Limin __ Do you Yahoo!? Yahoo! Mail - Easier than ever with enhanced search. Learn more. http://info.mail.yahoo.com/mail_250 -- http://mail.python.org/mailman/listinfo/python-list
Re: How is Python designed?
I think code says thing clearer, here I pasted
a simplified version of my implementation with
depth-tranverse. Note: this simplified version cannot
handle unary computation. To read the real version,
please read one source file of Yuan at:
http://cvs.sourceforge.net/viewcvs.py/yuan-language/yuan_devel/source/yn_expression.cpp?view=markup
I just mention a few points in the following codes:
1. evaluation is done during traverse.
2. no need to store "node"s or temporary variables in
a list/queue/stack.
3. when eval() is called, it knows the exact type of
the object.
class node{
// booleans to tell the type of node:
bool isVariable,isSomethingElse;
char oper; // operator
double value; // temporary value
something *tempVarForSomething;
node *left,*right; // pointers to its sons
node *parent; // pointer to its parent
void eval();
void trav();
};
void node::eval()
{
if(oper=='+')
value=left->value+right->value;
else if
}
void node::trav()
{
node *p=this;
while(1){
// go along "right" to reach a leaf:
while(p->right) p=p->right;
if(p->isVariable){
// get the value:
p->value=...;
}else if(p->isSomethingElse){
// do something else
}
if(!p->parent) break;
// if "p" is a "left" son:
if(p==p->parent->left){
// go back to "parent"
p=p->parent;
// evaluation:
p->eval();
if(p==this) break;
}
if(p==this) break;
// Now "p" must be a "right" son,
// jump to the "left"
p=p->parent->left;
}
}
--- "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> > No, in the depth-traversal implementation, a
> function
> > can avoid calling itself (at least in my
> > implementation it's like this).
>
> How so? It has to keep state of which nodes to visit
> - so instead of calling
> trav, you call functions to store and fetch nodes in
> a container like a
> stl-list. That's the same cost, function-call is
> function call.
>
> There is no difference - you simply decoupled the
> tree traversal from the
> evaluation - but combined, its the same effort. It's
> like in my second
> example with bytecodes - the traversal is done
> beforehand (and only once),
> and then the eval is only done on the nodes in a
> row.
>
> > Because you can write seperate functions: a
> function
> > for depth-traversal (say trav()) and another
> function
> > for evaluation (say eval()). trav() may call
> eval().
> > And eval() NEVER call other functions. For one
> > arithmetic tree, trav() is called once, and eval()
> is
> > called by trav() at each node. So it is not
> recursive.
> >> Now apart from that, I still fail to see where
> your
> >> method of evaluation has
> >> any speed gains.
> >
> > And if you inplement eval() as an "inline"
> function,
> > there will be no cost for function calls for
> eval().
> > In this way it can gain some speeds.
>
> No. Inlining works only when the actual type of your
> node is known, e.g.
> like this (Constant and Variable are both of type :
>
> {
> Constant left;
> Variable right;
>
> left.eval();
> right.eval();
> }
>
> Here the compiler can take advantage from the fact
> that it knows at
> compiletime which eval to inline
>
> But if you have
>
> {
> list nodes;
> for(nodes::iterator it = nodes.begin(); it !=
> nodes.end(); it++) {
> (*exp).eval();
>}
> }
>
> the compiler can't possibly know which node is in
> exp- so it has to resort
> to a vtable-lookup and a method call on the result.
>
> --
> Regards,
>
> Diez B. Roggisch
> --
> http://mail.python.org/mailman/listinfo/python-list
>
__
Do you Yahoo!?
Yahoo! Mail - Easier than ever with enhanced search. Learn more.
http://info.mail.yahoo.com/mail_250
--
http://mail.python.org/mailman/listinfo/python-list
ANN: Tao Scripting Language 0.9.0 beta released!
Dear all,
I am glad to announce in this mailing list that the
lastest version of Tao scripting language has come
out.
Welcome to try it out!
===
Here are some details:
===
Summary:
Tao is an object-oriented scripting language with dynamic typing
variables supporting complex data
structures. It has powerful text processing ability such
as string regular expression matching. It provides
built-in numerical data types such as complex number
and multi-dimensional numeric array, and their
corresponding operations and computations are very
convenient in Tao. It can be easily extended with C++,
through a simple and transparent interface.
Key Features:
1. Object-oriented ( syntax slightly similar to C++ ).
2. String regular expression with syntax support
( similar to Perl ).
3. Numeric types and their operations
( slightly similar to Matlab ).
4. Extendable with C++ through a simple and
transparent interface.
ChangeLog:
+ : added
! : changed
* : fixed
- : removed
Release: tao_0.9.0_beta:
! Matrix type is generalized to numeric array supporting
arbitrary dimensions and different precisions including
byte, short, int, float and double. Many operations are
also provided for numeric array.
+ Some convenient and powerful built-in functions are
implemented to manipulate numeric arrays, including
numarray(), apply(), noapply() and which() etc. Basic
mathematical functions are also supported for numeric
arrays.
+ A feature called transient variable is implemented for
convenient parameter passing in some situations.
+ Some "magic" functions which may take expressions
with transient variables as parameters to do some
computions on arrays and numeric arrays without
explicit looping and subindexing. These functions
include numarray(), apply() and noapply() for numeric
array; iterate() and iterget() for normal array;
and which() for both.
+ Some C++ types are provided for transparent passing
Tao types to C++ modules, so that only two C++
header files("taoCpptype.h" & "taoPlugin.h") are
required to develop C++ modules loadable by Tao
without linking to any additional libraries.
! The base class for TaoPlugin is changed from TaoBase
to TcBase, so that the developing of Tao plugins only
requires another header file "taoCpptype.h".
+ Basic string operations such as substring, insert,
replace and erase by subindexing. And a few functions
are added such as number(), pack() and unpack().
+ Added string regular expression matching for alternate
and grouping such as /(\d|\w)(@1:\D|\c)/.
+ Substring substitution by regular expressions.
! Embedding expression in regular expressions is changed.
+ More convenient subindexing is supported for array and hash.
+ Local variables.
+ yield statement to use routine as generator.
+ Many operators such composite assignment (+=, -=,
*=, /=,etc.), type comparision operators(=?,!?),
right operators( .#,.@,.%, etc.)
+ eval(): evaluate a block of codes represented as a string.
+ Loop control: for(e1,e2,e3), logic control: e1 ? e1:e2;
+ Other functions such as repeat(), about(), import(),
load(), time(), astime() and asctime() etc.
! Many changes including keywords: sub->routine,
continue->skip. commenting symbols are also changed.
* Some bugs.
Download:
http://prdownloads.sourceforge.net/taoscript/tao_0_9_0_beta.tar.gz?download
Document:
http://taoscript.sourceforge.net/An_Introduction_to_Tao_Language.pdf
HomePage:
http://taoscript.sourceforge.net
Contact:
Limin Fu: fu [dot] limin [dot] tao [at] gmail [dot] com
--
FU Limin
Homepage for Tao Language:
http://taoscript.sourceforge.net
Tao Language project at sourceforge.net:
http://sourceforge.net/projects/taoscript
--
http://mail.python.org/mailman/listinfo/python-list
questions on python script compiling for embedding
Dear all,
I am trying to embed python into another scripting language, to do this
I need to solve a number of problems on importing or compiling python
script. First let me state what exactly I want to do, that is, I want
the following syntax to be supported in the host language which I am
developing:
##
# scripts in the host language
routine Test()
do
println("printed by Test()");
end
global astring = "ASTRING";
# begin python scripts:
@begin(python)
def PyTest( s ):
print s
return 1000;
# access global variables from the host scripts
pystring = astring;
# call function defined in the host script:
Test();
@end(python)
# call a python function:
n = PyTest( "invoke python function" );
##
So there are the following problems come out naturally:
#1. can I compile a block of python script to get the list of
variables, classes and functions etc. (or at least the names) without
executing?
Because I need the host script to see the python definitions.
The Py_CompileStringFlags() seems to do the work. But it returns a code
object, which I don't know exactly and if it is possible to get the
list of variables, classes and functions from this kind of object.
##2. Can I pass a list global variables for such compiling?
Because I need python scripts also see the variables functions etc. defined in the host scripts.
*
For these two problem, a C API like this would be pefect:
PyObject* Py_CompileStringFlagsXXX( const char *str, const char *file, int start, PyObject *module, PyCompilerFlags *flags );
Different from Py_CompileStringFlags(), this function should take
another parameter (Python module object), which serve as a
**namespace**, to solve undefined names in the souce "str", and store
global variables, functions and classes etc defined in this source
string.
So the third question is:
###3. Is there some way, or how to do such thing as Py_CompileStringFlagsXXX() would do???
Of course, I do not expect such API should be added soon or even added.
Thanks a lot,
Limin
--
http://mail.python.org/mailman/listinfo/python-list
ANN: Dao, the official 1.0 version is released
Hi, This is to announce the first official release of Dao. Dao is a simple yet powerful object-oriented programming language with many advanced features including, soft (or optional) typing, BNF-like macro system, regular expression, multi-dimensional numeric array, closure, coroutine, asynchronous function call for concurrent programming etc. Dao provides a rich set of standard data types, methods and libraries. Dao is implemented as a light and efficient virtual machine with very transparent C programming interfaces, which make it easy to extend Dao with C/C++ or embed Dao into C/C++ programs. There have been a lot of improvements since the last release including: a lot of bug fixing and some broken feature fixing; several large implementation changes to improve the structure and clarity of the codes; and some implementation of new features. For the details, please have a look at: http://www.daovm.net/?page=dao_whats_new. Besides the improvements to the language and its implementation, the modules, tools, documentations and website associated with this language have also been improved greatly. The documentations are more complete than before, and are prepared in nice formats for easy referencing. A number of demos are also included in the release, including some programs for the The Computer Language Benchmarks Game, which can be tried out just for fun. One automatic tool (tools/autobind.dao) was developed using Dao itself, and was used to create most of the released Dao extending modules, by generating wrappers directly from the header files of the corresponding C/C++ libraries. This tool could also be used to wrap other C/C++ library as necessary. A new website that was developed using Dao itself too, has been setup at http://www.daovm.net, and is going to be the new official website of Dao. This new website will be established as a serious platform to promote the spreading of Dao and to grow a community of its users. Links: Home: http://www.daovm.net Document: http//www.daovm.net/?page=document_en Download: http//www.daovm.net/?page=download_en Forum: http//www.daovm.net/?forum Have fun. Limin -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: Dao, the official 1.0 version is released
Honest to say, there is no solid connection between Dao and Python. It's just that I had received some good suggestions and comments from these groups when I made a few previous announcements in these groups. So I guessed somebody might be interested in Dao, and thought it might be a good idea to announce it here again. Nevertheless, Python is one of the few languages from which Dao tried to learn something. I have paid a lot of my attention to Python during the development of Dao. Once a time I even created a module trying to allow calling Python functions and using python objects in Dao scripts, it was a long time ago, probably even before this language is named as Dao. Unfortunately I hadn't time to continue to develop that module. To Tim Greer and others: Some people may think this kind of announcement are off topic in a group for another language. This is not exactly true. This is still about programming, there are so many programmers out there, who knows if there would be somebody interested in a new language. This announcement does not mean to threaten any language, I don't even think it is somewhere close to that. So take it easy. On 3月6日, 下午7时13分, [email protected] wrote: > Limin> This is to announce the first official release of Dao. > > What's the connection to Python? > > -- > Skip Montanaro - [email protected] -http://www.smontanaro.net/ -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: Dao, the official 1.0 version is released
> > i agree it's not clear how this is related to python (although i can see > the influence), but it does look like a nice language. thanks. > > > one thing i was surprised to find missing was that the discussion of types > doesn't include classes (the discussion of macros doesn't include Actually the documentation about types does not mean to explain the types in a systematic way. It just tries to explain how to practically use them implicitly and explicitly, and to point out where one should pay attention. Classes surely should be discussed, but it didn't come into my mind when I prepared the documentation. It will be discussed when I update the document. > types, > but that is more understandable). i am wondering if you have hidden > problems related to co and contra variance of types (like in java > generics). I have paid attention to the variance of types in some situations, but I am not very sure if it is without problems. Until now, I still feel there are still many things to be improved in the typing system. It would not be surprising if there are hidden problems regarding this. > > also, why is "@" needed as well as yield? in python, the presence of > yield makes "@" implicit (i think). > You are right. I will change this. Thank you for pointing out this. I am glad that, every time I announced the language in the python mailing list, I received good comments and suggestions more often than in other mailing lists and groups, that's why python mailing list is one of the first places coming into my mind when I plan for an announcement of Dao;) > > andrew > > > Limin Fu wrote: > > Hi, > > > > This is to announce the first official release of Dao. > > > -- Limin Fu http://www.daovm.net -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: Dao, the official 1.0 version is released
> i agree it's not clear how this is related to python (although i can see > the influence), but it does look like a nice language. thanks. > > one thing i was surprised to find missing was that the discussion of types > doesn't include classes (the discussion of macros doesn't include types, Actually the documentation about types does not mean to explain the types in a systematic way. It just tries to explain how to practically use them implicitly and explicitly, and to point out where one should pay attention. Classes surely should be discussed, but it didn't come into my mind when I prepared the documentation. It will be discussed when I update the document. > but that is more understandable). i am wondering if you have hidden > problems related to co and contra variance of types (like in java > generics). I have paid attention to the variance of types in some situations, but I am not very sure if it is without problems. Until now, I still feel there are still many things to be improved in the typing system. It would not be surprising if there are hidden problems regarding this. > > also, why is "@" needed as well as yield? in python, the presence of > yield makes "@" implicit (i think). You are right. I will change this. Thank you for pointing out this. I am glad that, every time I announced the language in the python mailing list, I received good comments and suggestions more often than in other mailing lists and groups, that's why python mailing list is one of the first places coming into my mind when I plan for an announcement of Dao;) > > andrew > > Limin Fu wrote: > > Hi, > > > This is to announce the first official release of Dao. > > -- Limin Fu http://www.daovm.net -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: Dao, the official 1.0 version is released
I don't think there is confusion here, because the Microsoft database access method DAO is not a programming language. > > Whatever it is, the name does tend to lend confusion with the older > Microsoft database access method DAO (which was superceded by ADO). > -- >WulfraedDennis Lee Bieber KD6MOG >[email protected] [email protected] >HTTP://wlfraed.home.netcom.com/ >(Bestiaria Support Staff: [email protected]) >HTTP://www.bestiaria.com/ > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Limin Fu http://www.daovm.net -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: Dao, the official 1.0 version is released
On Sat, Mar 7, 2009 at 5:14 PM, MRAB wrote: > Limin Fu wrote: > > Dennis Lee Bieber wrote: > >> Whatever it is, the name does tend to lend confusion with the older >>> Microsoft database access method DAO (which was superceded by ADO). >>> >> >> I don't think there is confusion here, because the Microsoft database >> access method DAO is not a programming language. >> >> And anyway, the Chinese got there first! :-) Perfectly agreed, hehe -- Limin Fu http://www.daovm.net -- http://mail.python.org/mailman/listinfo/python-list
ANN: Dao 1.0 preview version is released
Hi, I am please to announce a preview release of Dao (1.0). Dao is a simple yet powerful object-oriented programming language featured by, optional typing, BNF-like macro system, regular expression, multidimensional numeric array, asynchronous function call for concurrent programming etc. Since the last beta release (2006 november), a number of new features have been added to the language with some significant improvements on the implementation. Here I will just list some of them: 1. Added a new typing system, so that the type of an variable can be either declared explicitly or inferred implicitly, and type checking is performed at compiling time when possible. More over the type information is used for function overloading and function specialization (with type-optimized VM instructions) according to paramter types. Some types can be compounded into new types, e.g., list, tuple>... 2. A flexible macro-system that allows writting macro in a form close to BNF, and can be used to define new syntax; 3. Added Asynchronous Function Call (AFC) and Message Passing Interface (MPI) for further support for concurrent and distributed programming (still experimental); 4. Added a few new data types, in particular, among which, there is the new tuple type in which each of the items is typed independently, for example, if a tuple is consisted of an integer and a string, then the type of the tuple will be tuple; Moreover the items of a Dao tuple can have field names. 5. The internal data storage scheme is improved to reduce memory overheads for simple types. 6. Added special support for the main() function, so that the comand line arguments are mapped to the function parameters, and are checked against the paremeter types of main(). 7. Improved representation of C/C++ types, so that their inheritance relationships can be still valid in Dao, and they can be derived by Dao classes directly. Moreover, this release has included a tool (tools/autobind.dao) which can do semi-automated wrapping of C/C++ libraries. In fact, many of the modules released this time are generated by this tool. Just to list the modules released this time: DaoCamellia (image processing), DaoCGI (CGI Web programming), DaoCLoader (running time wrapping of C libraries, slightly similar to the ctype module of Python), DaoDataModel (database handling, can be used to set up mappng between data tables and Dao class types), DaoFastCGI (CGI Web programming), DaoLapack (linear algebra library), DaoMagick (image processing), DaoMGL (math plotting), DaoMySQL (database), DaoOpenGL (3D graphics), DaoSDL (multi-media), DaoTCC (embedding C codes into Dao scripts), DaoXML (handling XML documents and fetching web pages from web servers), DaoZlib (compression), DaoVTK (3D data and model visualization). I believe this release has become suitable for some practical applications, and worth to be tried out. Then a formal release of the 1.0 version will be made available during this august or september. I would be very grateful, if anyone can give me some suggestions for improvement, and feature requests are of couse also welcome. Thanks and enjoy, Limin homepage: http://www.xdao.org sourceforge project: http://sourceforge.net/projects/daoscript/ download: https://sourceforge.net/project/showfiles.php?group_id=141871&package_id=273540&release_id=594971 -- http://mail.python.org/mailman/listinfo/python-list
