Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Regular expression code implementation review between Tcl vs Python

Reply
Thread Tools

Regular expression code implementation review between Tcl vs Python

 
 
K_Lee
Guest
Posts: n/a
 
      11-11-2003
I documented the regex internal implementation code for both Tcl and Python.

As much as I like Tcl, I like Python's code much more.
Tcl's Stub interface to the external commands is confusing to
outsider. I still don't get why the stub interface is needed.

One aspect I don't understanding about python is that the Python
language itself is object oriented and all the internal is implement
as C object. Why not C++ object?



http://www.slink-software.com/W/SrcD...-2.3.sdoc/N_97

Regular Expression
initregex - regexmodule.c:646
regex_global_methods - regexmodule.c:635
regex_compile - regexmodule.c:410
regex_symcomp - regexmodule.c:637
regex_match - regexmodule.c:638
regex_search - regexmodule.c:639
re_compile_initialize - regexpr.c:448
re_compile_pattern - regexpr.h:83


http://www.slink-software.com/W/SrcD....4.4.sdoc/N_92

Regular Expression
TclRegexp - tclRegexp.h:35
Tcl_RegExpCompile - tclRegexp.c:141
CompileRegexp - tclRegexp.c:147
Tcl_RegExpExec - tclRegexp.c:173
RegExpExecUniChar - tclRegexp.c:213
RegExpExecUniChar - tclRegexp.c:291
 
Reply With Quote
 
 
 
 
Ralf Fassel
Guest
Posts: n/a
 
      11-11-2003
* http://www.velocityreviews.com/forums/(E-Mail Removed) (K_Lee)
| http://www.slink-software.com/W/SrcD....4.4.sdoc/N_92

<quote>
If you still like to use this webbase application, please enable
the cookie in your browser and try again.
</quote>

You bet I won't. If you want people to read your stuff, let them read
it with no obstacles.

R'
 
Reply With Quote
 
 
 
 
Helmut Giese
Guest
Posts: n/a
 
      11-11-2003
On 11 Nov 2003 07:58:14 -0800, (E-Mail Removed) (K_Lee)
wrote:

>I documented the regex internal implementation code for both Tcl and Python.
>
>As much as I like Tcl, I like Python's code much more.
>Tcl's Stub interface to the external commands is confusing to
>outsider. I still don't get why the stub interface is needed.

Simple. Let's create an example.
If you don't use it, than you have to link your extension against the
current version of Tcl, say, tcl84.lib. Easy, no problem.

But tomorrow Tcl 8.5 comes out and you have the problem, that
tcl85.dll is running (used by tclsh or wish) and your extension needs
tcl84.dll, since (during its linking) you created an un-breakable
connection between the two.
Solutions:
- Stick with the older version of Tcl.
- Re-compile the extension now linking against Tcl85.lib (and repeat
for Tcl 8.6, 8.7, etc.)
- Don't link against Tcl8.x lib but use the 'stub interface'. This
avoids creating this fixed connection between your extension and a
particular version of Tcl, and you can use the extension with any
future version of Tcl and be happy ever after (unless the stub
interface itself changes, but this will be in a completely different
time frame- if it should ever happen at all).

>One aspect I don't understanding about python is that the Python
>language itself is object oriented and all the internal is implement
>as C object. Why not C++ object?

Just my 0.02: I suppose that C++ compilers still differ a lot more on
different platforms (concerning their conformance to the standard)
than C compilers do. So, if portability is high on your check list, C
still is the language of choice - but in the future C++ will catch up
(IMHO).
Best regards
Helmut Giese

 
Reply With Quote
 
3seas
Guest
Posts: n/a
 
      11-11-2003
Ralf Fassel wrote:

> * (E-Mail Removed) (K_Lee)
> | http://www.slink-software.com/W/SrcD....4.4.sdoc/N_92
>
> <quote>
> If you still like to use this webbase application, please enable
> the cookie in your browser and try again.
> </quote>
>
> You bet I won't. If you want people to read your stuff, let them read
> it with no obstacles.
>
> R'


hehe, I hit that wall to, as the two recent posts by them, the subject line
of, caught my attention. Anyway I went to the main or base of the link..

the posts are examples of use of their software and really not python
specific. But if they wrote it in python, it'd likely be more cross
platform compatable, as far as running the server application.

--
3 S.E.A.S -- Virtual Interaction Configuration (VIC)
Changing how we preceive and use computers
email @ translate not to net, remove capitol letters, one .
web @ http://threeseas.net

 
Reply With Quote
 
lvirden@yahoo.com
Guest
Posts: n/a
 
      11-11-2003

According to K_Lee <(E-Mail Removed)>:
:Tcl's Stub interface to the external commands is confusing to
utsider. I still don't get why the stub interface is needed.

Check out the explanation at http://wiki.tcl.tk/stubs to understand
why the stub interface is needed.
--
<URL: http://wiki.tcl.tk/ > In God we trust.
Even if explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.
<URL: (E-Mail Removed) > <URL: http://www.purl.org/NET/lvirden/ >
 
Reply With Quote
 
Alex Martelli
Guest
Posts: n/a
 
      11-11-2003
K_Lee wrote:
...
> One aspect I don't understanding about python is that the Python
> language itself is object oriented and all the internal is implement
> as C object. Why not C++ object?


Using an OO language doesn't necessarily make implementing another
OO language any easier, when the object models are mismatched (and
they almost invariably are). Look at other opensource OO languages,
such as Ruby, and you'll see they also use C, not C++.

Actually, a small and carefully selected subset of C++ might surely help,
_if_ there was consensus on what that subset should be and net of
the work of hashing that consensus out. But C++ just isn't very much
in the opensource culture -- C is just much more popular. Eric Raymond's
book "The Art of Unix Programming" doesn't address the issue directly but
much of what it says about "Unix culture" extends directly to opensource
(as he notes, too). There are such values as an admiration for simplicity
(cfr. C's principle, as per the Rationale of the C Standard, "provide only
one way to perform an operation", and Python's corresponding "there ought
to be one, and preferably only one, obvious way to do it") which militate in
favour of C (which may not have reached simplicity everywhere but surely
did and does always strive for it) and against C++ (which never gave
language-simplicity a high priority level among its many design goals); even
in subcultures that overtly reject such principles (e.g., Perl's) they may
still have some subconscious-level effect.

I used to bemoan this back when I was a C++ not-quite-but-close-guru.
3 years later, with little use of C++ in the meantime, I have forgotten more
about C++ than most of it practitioners will ever learn... but C is just
never forgotten, like how to swim or how to ride a bicycle. So, I am not
any longer so sure if my "bemoaning" was warranted.


Alex

 
Reply With Quote
 
Rainer Deyke
Guest
Posts: n/a
 
      11-11-2003
Alex Martelli wrote:
> Using an OO language doesn't necessarily make implementing another
> OO language any easier, when the object models are mismatched (and
> they almost invariably are).


Using RAII to automate reference count management would certainly help in
implementing Python, even if it is a feature that Python itself doesn't
have.


--
Rainer Deyke - (E-Mail Removed) - http://eldwood.com


 
Reply With Quote
 
Irmen de Jong
Guest
Posts: n/a
 
      11-11-2003
Hello Alex,

you may find this rather unusual but I wanted to say that
I often read your postings in c.l.python in admiration.

They usually are very instructive, explanatory, and contain
a lot of knowledge about Python and things related. A lot can
be learned from them indeed. I sometimes wonder how you find
the time to write so many in c.l.p (and usually quite long
and detailed too)...

But also am I yealous of the quality of the language used
in them... Though I'm not a native English speaker (like you,
right?) I think I master the language fairly well, but
not nearly as well as you

Just wondering and wanted to let you know.

Regards,
Irmen de Jong.
(NL)

 
Reply With Quote
 
K_Lee
Guest
Posts: n/a
 
      11-12-2003
Ralf Fassel <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)-local.de>...
> * (E-Mail Removed) (K_Lee)
> | http://www.slink-software.com/W/SrcD....4.4.sdoc/N_92
>
> <quote>
> If you still like to use this webbase application, please enable
> the cookie in your browser and try again.
> </quote>
>
> You bet I won't. If you want people to read your stuff, let them read
> it with no obstacles.
>
> R'

Sorry about that.

Will work on that. Here's the reason why we need the cookie at
this point.

The SDoc is a web document (like blogging ) where any number
of users (current we have ~800 users at our website) can write and
read
any topics in the document. The topics are organized like
a directory tree. Each users can collaps and expand his/her owner
topics without changing the view of other users.

For example, we have a lots internal webbase document with
thousand of topics.

But at any this moment for the TCL document, I really
only care about regex but not the network subtree. My current view
have the network part is collaps state and the regular expression is
is full expand state.

We use cookie to keep track of each topics state in every document
for every user not to keep track of what they view but to help
minimize
the overload of information when the topic tree is shown.


I really didn't want to implement that features with cookie initially,
but I had tough time finding other "right" method to do it. Now I
believe
we can implement it with the embedded the user id as part of URL or
?uid=12345 append at the end of every URL.

This will allows user who turn off cookie to browse the page. But if
the
reason for turnning off the cookie is so the website can't track you.
It doesn't really solve the problem.

Either way, any dynamically generated webpage can still track you with
the id embedded into the URL in every reponse even when you turn off
the cookie.

BTW, I see a lot of more other info from the weblog that is far more
interesting than cookies. Cookie are kind boring from analyzing the
webtraffic point of view.


Sorry again for the "obstacles".



K_Lee
 
Reply With Quote
 
K_Lee
Guest
Posts: n/a
 
      11-12-2003
(E-Mail Removed) (Helmut Giese) wrote in message news:<(E-Mail Removed)>...
> On 11 Nov 2003 07:58:14 -0800, (E-Mail Removed) (K_Lee)
> wrote:
>
> >I documented the regex internal implementation code for both Tcl and Python.
> >
> >As much as I like Tcl, I like Python's code much more.
> >Tcl's Stub interface to the external commands is confusing to
> >outsider. I still don't get why the stub interface is needed.

> Simple. Let's create an example.
> If you don't use it, than you have to link your extension against the
> current version of Tcl, say, tcl84.lib. Easy, no problem.
>
> But tomorrow Tcl 8.5 comes out and you have the problem, that
> tcl85.dll is running (used by tclsh or wish) and your extension needs
> tcl84.dll, since (during its linking) you created an un-breakable
> connection between the two.
> Solutions:
> - Stick with the older version of Tcl.
> - Re-compile the extension now linking against Tcl85.lib (and repeat
> for Tcl 8.6, 8.7, etc.)
> - Don't link against Tcl8.x lib but use the 'stub interface'. This
> avoids creating this fixed connection between your extension and a
> particular version of Tcl, and you can use the extension with any
> future version of Tcl and be happy ever after (unless the stub
> interface itself changes, but this will be in a completely different
> time frame- if it should ever happen at all).
>
> >One aspect I don't understanding about python is that the Python
> >language itself is object oriented and all the internal is implement
> >as C object. Why not C++ object?

> Just my 0.02: I suppose that C++ compilers still differ a lot more on
> different platforms (concerning their conformance to the standard)
> than C compilers do. So, if portability is high on your check list, C
> still is the language of choice - but in the future C++ will catch up
> (IMHO).
> Best regards
> Helmut Giese


Helmut, Thanks for the 0.02.

The "normal" os's dll, .so system use dlsym() call to resolve the
function "string_name" to function pointers. They seems to work for
upward compatibilities for most of the cases.

But I kind understand the argument from the statics link library
point of view, just think the price is too high for
such "features". I guess the TCL original goal was also to support
Win16, DOS, etc.

For example, here's the python's code for regexp methods functions
pointers.
They are cleaner more modular than the TCL's stub table. (My 0.005)

http://www.slink-software.com/W/SL_T...5/LN_635#L_632


static struct PyMethodDef regex_global_methods[] = {
{"compile", regex_compile, METH_VARARGS},
{"symcomp", regex_symcomp, METH_VARARGS},
{"match", regex_match, METH_VARARGS},
{"search", regex_search, METH_VARARGS},
{"set_syntax", regex_set_syntax, METH_VARARGS},
{"get_syntax", (PyCFunction)regex_get_syntax, METH_NOARGS},
{NULL, NULL} /* sentinel */
};


Here's the code for TCL Stub:
http://www.slink-software.com/W/SL_T...0/LN_647#L_644

....
Tcl_RegExpCompile, /* 212 */
Tcl_RegExpExec, /* 213 */
Tcl_RegExpMatch, /* 214 */
Tcl_RegExpRange, /* 215 */
....
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to build a loadable tcl dll with visual studio (microsoft C compiler)?[crosspost in comp.lang.tcl and comp.lang.c++] Michael Reichenbach C++ 5 02-08-2010 02:38 PM
Inline::Tcl vs. Inline::Tcl Mumia W. Perl Misc 0 08-23-2006 04:09 PM
Matching abitrary expression in a regular expression =?iso-8859-1?B?bW9vcJk=?= Java 8 12-02-2005 12:51 AM
regular expression for perl, tcl, sed, grep, awk Jay eL Perl Misc 2 12-09-2003 04:23 AM
Dynamically changing the regular expression of Regular Expression validator VSK ASP .Net 2 08-24-2003 02:47 PM



Advertisments