Re: [PerlChina] perlchina的注记

2014-08-26 Thread Dongxu Ma
说到商业公司的话,您漏掉了2家当初比较有名的:摩根士丹利和亚马逊。这两家公司是当初借着Perl5的流行把自己的公司IT搭建起来的。我在前者工作了7年,因为个人也爱好这门语言,对摩根士丹利里Perl5的发展情况也是蛮了解的,里面随处可见Perl的踪影。High
Order
Perl的序言里也阐述了Hildo代表大摩的帮助。大摩自从在上海落户开发中心以来,也在上海开辟了一部分和Perl相关的职位,间接推动了这门语言在国内的发展。最近公司还有在招聘这方面的职位。


2014-08-25 16:04 GMT+08:00 Liu Yubao yubao@gmail.com:

 好怀旧。

 如果ParrotVM能火起来,这还是很好玩的,但感觉这货没啥指望的样子。Perl 6么,随它去吧。喜欢Perl的话Perl 5才是精髓,Perl
 6完全是另一个东西,可恨还顶着Perl的名号,败坏!

 Perl在国内的普及应该很大程度归功于Learning
 Perl第四版的翻译,初看此书惊为天物。以及Linux的普及,流行时间跟Linux进入中国差不多,九九年前后。但随着Python和Java普及,
 Perl渐入下风。

 在流行期间,BBS起了推波助澜的作用,我当年混水木的,现在还不时去灌灌。

 感觉语言的流行必须有商业公司大力推动,或者创始人非常牛逼,忽悠能力超好。

 On Friday, August 22, 2014, Yisong Zhen zhenyis...@gmail.com wrote:

 以下内容会在我的blog http://blog.sciencenet.cn/u/zhenyisong
 上发表,有历史知情者或者提供其他线索的人士,请与我联系。


 Perl作为一种计算机语言,早在1987年由美国人Larry Wall创建。这段历史以及Larry
 的个人自传都可以从维基百科得到。随后的阶段,荷兰人Rossum(1989)创建了Python。加拿大人Gosling(1990)创建了Java
 。日本人松本行弘(1995)年创建Ruby。丹麦人Lerdorf(1995)创建了PHP。之前,Ritchie和Thompson(1971)创建了
 C语言,也就是我在大学从谭浩强那本书学到的。中国人至今还在不停地学习各种语言。

 Perl在业界的流行程度有比较,最近的RedMonk ranking的排名是第11位,勉强在第一方阵吧。RedMonk的样本主要采集于GitHub
 和Stackoverflow。当然,有可能出现样本偏差,例如Github更注重新的语言,而早期的Perl或者Java都放在Sourceforge
 上面,Stackoverflow则反映的更多的是语言的技术难度。此外,黑客经常使用的技术、公司招募的条件、相关计算机语言的书籍销量以及GOOGLE
 的查询频率,这些都能体现目前计算机语言的“流行”程度。总之,Perl的趋势是在下滑,而且有脱离第一方阵的倾向,这个结论可以参考
 TIOBE-Index。Perl的最高点大约是2005年,随后开始下滑(目前来看,Java仍旧是排名靠前,C++和C是开发者和雇主的偏爱)。

 在中国,由于yahoo中国的退出,Perl似乎在国内衰落了。由于Perl语言的创造者Larry Wall来北京, PerlChina
 组织的最近一次讨论会大约有30人参加。有幸和老Larry合影。Larry认为Perl语言可以实施“freewill
 ”,这是哲学层面的比较。我的浅薄知识可能无法领会Larry的这个说法。毫无疑问,上帝具有“free will
 ”,而对于人类,这个命题是否成立,目前仍存在争论。我目前是这么认为,曾经一种流行的CGI语言,被强有力的新挑战者替代。

 不过,我一直存疑的问题是,Perl是如何进入中国的?Larry在1987年将Perl1.0发布到comp.sources.misc
 新闻组,那时中国互联网还处于雏形,应该最早出现于中科院高能物理所。Perl4最后结束的时间是1994,1994
 年中国的互联网才与国际的互联网沟通。那时我才刚进入大学。因此,Perl
 是最早在高校流传,还是业余的爱好者首先推广,是官方还是民间自发的选择?由于我的学识有限,所以这个问题有待进一步的考证。但我粗浅的了解,Perl
 在中国的普及应该是民间自发的,没有学校和官方的组织和身影。而PerlChina组织应该是Perl在中国普及的一个基石和探索。

 PerlChina实际上是Perl在中国普及的一个民间缩影。它似乎成立于2001年冬天。有一名计算机语言爱好者Tsingson
 注册了现有的域名(不过,现在的域名持有者是Qiang,可以通过whois查询这段历史的遗迹)。我在采访PerlChina
 的诸位前辈的时候,我的一个问题就是:“什么时候想要建立一个PerlChina
 的组织?当时的动机是什么?”。然而就是这个简单的问题,现在也无法考证,也可能是时间久远,记忆的片段更加模糊,很难确切地描述当时的动机。但肯定的是,
 PerlChina是非盈利性机构,当然,每次PerlChina的大会,都有网络公司的慷慨解囊,或为之提供场地或免费提供午餐。

 Perl-China曾经的站长,包括:chunzi,曾在2001-2003年主持Perlchina的站点管理工作。Chunzi
 退出管理后,目前从事的工作仍和Perl相关,在公司工作中仍然全面使用Perl语言开发、维护公司的项目。 Hoowa(网名)是2003-2004
 年参与PerlChina的站点管理的。Hoowa目前不再参与Perl的中国推广活动。目前他所在的公司也少部分利用Perl
 来完成一些项目。当然,他目前的工作与Perl的关系不大,这似乎是他完全退出PerlChina的原因之一。曾经的参与者:Nomas(2004年底
 -2010年),由于工作紧凑,所以辞去站长的职责,但工作中仍然用到Perl。目前的维护者是Achilles。PerlChina
 站长的交接工作是自然而然的,没有特别的行政指令或者出于个人利益的诉求,这种自发的传承使得PerlChina的运行处于小众而稳定的状态。

 根据回忆,早期Perl的实践者包括:Boysss(?)四川省某工厂厂长,爱好写代码,曾在电脑报撰写文章。据chunzi回忆,他最早期接触Perl
 实际上是来自于boysss的翻译工作。6y6(六月六)翻译Perl的CGI文档。Netawk,福建省硬件工程师。花斑猪,Perl
 计数器的开发。华炼,曾在yahoo
 中国工作,开发网络商店;小林(斗牛士),全名林兴华,曾在瀛海威和锐讯工作过,曾参与移动互联网的开发;飞云小侠,据说毕业于北大,曾参与网络旅游。我想,早期实践者的踪迹已经很难寻觅到了,
 Perl究竟是如何扩散的,很难找到源头。

 不过,我觉得类似于美国篮球职业联赛,应该建立中国Perl名人堂,评价的唯一标准是对Perl
 的深层理解和应用。当然,我浅薄的知识还无法判断,有佛头著粪之嫌。在我的其启发下,我采访的其中几位PerlChina
 的站长提名了若干人,但是我随后的考虑,觉得这种方式不太妥当,我既不是江湖上的百晓生,也没有能力评价中国Perl
 的程序员。只能拾人牙慧,而且很容易引起不必要的误解。不过,PerlChina应该有自己的名人堂,用以激励后来的Perl使用者,并向Perl
 发展起到重要贡献的程序员致敬。

 如果有更多的公司愿意招聘Perl程序员,那么Perl的发展肯定是无可限量的。目前采用Perl作为开发工具的有这么几家大的公司,如英国广播公司(
 BBC),互联网电影资料库(IMDB),Craigslist等等。Quora上曾经有一个帖子是关于Perl有哪些大的公司使用。Vicky
 Brasseur在GitHub发布了一个数据库,用来搜集目前使用Perl的公司。国内我几乎不太了解。Achilles给我的一封信指出,目前 国内
 蓝汛、乐看网、音悦台、若比邻、阿里、去哪儿、DeNA等在采用Perl语言,而PerlChina
 在此方面做得工作乏善可陈。我想,执着的兴趣和高位数的薪金,将绝对促进Perl在国内的发展和普及。现在Perl几乎边缘化了。



 对于历史的回顾,我对于Perl在中国以及PerlChina的历史仍有很多疑点。比如,与台湾相比,Perl为什么没有在大陆地区发展起来(这个问题是
 chunzi提出的)?原因是什么?我们和欧美的差距具体在哪里?有哪些成功的经验可以移植?又有哪些中国本土的文化可以借用,从而通过PerlChina
 推动Perl在中国的发展?CPAN上有多少模块是大陆Perl爱好者提供的作品?下载量是多少?还有哪些Perl
 的前辈和传奇人物应该在名人堂内以及如何界定这种遴选标准?当然,还有很多细节有待考证,例如,PerlChina
 组织的全国性会议有几次?会议地点和人数?谁是赞助商?有哪些人士参与会议的组织?有多少人通过PerlChina找到了工作?

 本文主要采访了PerlChina历史上的站长,根据他们的回忆并蒙许可将主要内容通过我的博客发布。如有历史上的知情者,请一定联系我。





 附件-采访时的部分问题:

 为什么您将Perl的工作转移给别人,是放弃Perl在中国的推广了?

 您现在的工作是什么?还用Perl吗?还会关注Perl的发展吗?

 交接工作的原则是什么?

 你知道还有哪些官方或者是民间的Perl的推广计划吗?

 您能介绍还有哪些Perl的前辈或者是传奇人物?

 Perl是如何在中国传播的?是自发的还是有组织的?从高校开始还是民间的网络高手?

 如何查询来自大陆地区贡献的CPAN的作品?

 --

 //---
 //   We have a hunger of the mind which asks for knowledge
 //   of all around us, and the more we gain, the more is
 //   our desire; the more we see, the more we are capable
 //   of seeing.

 //---
 @
 YiSong Zhen, Ph.D

 State Key Laboratory of Cardiovascular Disease,
 Fuwai Hospital  Cardiovascular Institute,
 Chinese Academy of Medical Sciences,
 Peking Union Medical College,
 Beijing 100037, Beilishilu 167
 P.R.China
 http://www.cardiosignal.org
 Tel: 86-10-60866105 (lab)

 @

 --
 您收到此邮件是因为您订阅了Google网上论坛中的“PerlChina Mongers 讨论组”论坛。
 要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到perlchina+unsubscr...@googlegroups.com。
 

Re: Audio-TagLib

2011-02-08 Thread Dongxu Ma
Hi Geoffrey,

Great news. I am very happy to hand it over.
I am really busy on my fulltime job in past 3 years.
Will make you co-maintainer, please release it under your cpan id.

cheers,

On Mon, Feb 7, 2011 at 10:04 PM, Geoffrey Leach ge...@hughes.net wrote:

 Hello.

 I've worked on Audio-TagLib 1.50_01 to the point where it installs with
 taglib v1.5 without any test failures.  I'd like to release this as
 version 1.50 and then go on to make it compatible with taglib v1.6.x.

 This would be easiest if you would authorize me to be co-maintainer.
 Alternatively, if you would prefer to maintain sole control of the
 source, I'd be happy to forward to you the modified sources.

 Either way, I'd appreciate a reply.

 Best regards,

 Geoffrey Leach (gle...@cpan.org)




-- 
-Dongxu


Re: Perl 6 Microgrants. Now accepting proposals.

2007-03-23 Thread Dongxu Ma

Hi all,

I am recently working on the QT4/KDE4 bindings for p5.
First cpp headers are parsed by a grammar based on Parse::RecDescent,
The production of latest dev release Parse-QTEDI-0.02_01 is quite stable,
presenting all related interface information of cpp .h.

I will continue to make it available in p5. And myself do have a plan to
introduce them in p6. It will be nice if someone can do so in parallel with
me (I mean, for p6). Since: 1. my knowledge on p6 sucks ;-) 2. currently
I haven't got enough time.

PS: It is very glad to see such information, really. In my opinion p6 indeed

needs trying to draw as many connections as possible with other
outstanding tool/project outside perl world. KDE is such a place too.

PS2: my project page:
   http://code.google.com/p/dongxu/wiki/QTEDI
   http://code.google.com/p/dongxu/wiki/PerlQT

-- Forwarded message --
From: Jesse Vincent [EMAIL PROTECTED]
Date: Mar 22, 2007 11:04 AM
Subject: Perl 6 Microgrants. Now accepting proposals.
To: perl6-internals@perl.org, perl6-language@perl.org,
perl6-compiler@perl.org, perl5-porters@perl.org

I'm pleased to announce the inaugural Perl 6 Microgrants program.
Best Practical Solutions (my company) has donated USD5,000 to The
Perl Foundation to help support Perl 6 Development.  Leon Brocard,
representing The Perl Foundation's grants committee, will work with
me to select proposals and evaluate project success.  We'll be making
USD500 grants to worthy Perl 6 related efforts. We're hoping to fund
a range of Perl 6-related projects over the life of the grant
program.  Accepted grants might be for coding, documentation, testing
or even writing articles about Perl 6. The program isn't tied to any
one implementation of Perl 6 -- We're interested in seeing proposals
related to Pugs, Perl 6 on Parrot, Perl 6 on Perl 5 or any other Perl
6 implementation.  Generally, we're interested in seeing projects
that can be completed in 4-6 calendar weeks.

Submitting a grant proposal
---

To submit a grant proposal, please email us at perl6-
[EMAIL PROTECTED] with the following information:

* A two to three paragraph summary of the work you intend to do
* A quick bio - Who are you? Is there opensource work you've done
that we should have a look at?
* A brief description of what success will mean for your project -
How will we know you're done?
* Where (if anywhere) you've discussed your project in the past
* Where you'll be blogging about your progress. (Twice-weekly blog
posts are a requirement for getting your grant money)

We'll be accepting proposals on a rolling schedule. We expect to pay
out these first 10 grants over the course of the summer. Depending on
how things go, we'll then either find more money for more grant
programs or we'll wind up the program and move on to other endeavors.

We're really excited to get rolling. Submit your proposals early and
often. Don't let somebody else beat you to the punch ;)

Best,

Jesse



--
Cheers, Dongxu
__END__
http://search.cpan.org/~dongxu


PGP.sig
Description: PGP signature


Re: Perl 6 Microgrants. Now accepting proposals.

2007-03-22 Thread Dongxu Ma

Hi all,

I am recently working on the QT4/KDE4 bindings for p5.
First cpp headers are parsed by a grammar based on Parse::RecDescent,
The production of latest dev release Parse-QTEDI-0.02_01 is quite stable,
presenting all related interface information of cpp .h.

I will continue to make it available in p5. And myself do have a plan to
introduce them in p6. It will be nice if someone can do so in parallel with
me (I mean, for p6). Since: 1. my knowledge on p6 sucks ;-) 2. currently
I haven't got enough time.

PS: It is very glad to see such information, really. In my opinion p6 indeed

needs trying to draw as many connections as possible with other
outstanding tool/project outside perl world. KDE is such a place too.

PS2: my project page:
   http://code.google.com/p/dongxu/wiki/QTEDI
   http://code.google.com/p/dongxu/wiki/PerlQT

-- Forwarded message --
From: Jesse Vincent [EMAIL PROTECTED]
Date: Mar 22, 2007 11:04 AM
Subject: Perl 6 Microgrants. Now accepting proposals.
To: perl6-internals@perl.org, perl6-language@perl.org,
perl6-compiler@perl.org, perl5-porters@perl.org

I'm pleased to announce the inaugural Perl 6 Microgrants program.
Best Practical Solutions (my company) has donated USD5,000 to The
Perl Foundation to help support Perl 6 Development.  Leon Brocard,
representing The Perl Foundation's grants committee, will work with
me to select proposals and evaluate project success.  We'll be making
USD500 grants to worthy Perl 6 related efforts. We're hoping to fund
a range of Perl 6-related projects over the life of the grant
program.  Accepted grants might be for coding, documentation, testing
or even writing articles about Perl 6. The program isn't tied to any
one implementation of Perl 6 -- We're interested in seeing proposals
related to Pugs, Perl 6 on Parrot, Perl 6 on Perl 5 or any other Perl
6 implementation.  Generally, we're interested in seeing projects
that can be completed in 4-6 calendar weeks.

Submitting a grant proposal
---

To submit a grant proposal, please email us at perl6-
[EMAIL PROTECTED] with the following information:

* A two to three paragraph summary of the work you intend to do
* A quick bio - Who are you? Is there opensource work you've done
that we should have a look at?
* A brief description of what success will mean for your project -
How will we know you're done?
* Where (if anywhere) you've discussed your project in the past
* Where you'll be blogging about your progress. (Twice-weekly blog
posts are a requirement for getting your grant money)

We'll be accepting proposals on a rolling schedule. We expect to pay
out these first 10 grants over the course of the summer. Depending on
how things go, we'll then either find more money for more grant
programs or we'll wind up the program and move on to other endeavors.

We're really excited to get rolling. Submit your proposals early and
often. Don't let somebody else beat you to the punch ;)

Best,

Jesse



--
Cheers, Dongxu
__END__
http://search.cpan.org/~dongxu


PGP.sig
Description: PGP signature


Re: Perl 6 Microgrants. Now accepting proposals.

2007-03-22 Thread Dongxu Ma

Hi all,

I am recently working on the QT4/KDE4 bindings for p5.
First cpp headers are parsed by a grammar based on Parse::RecDescent,
The production of latest dev release Parse-QTEDI-0.02_01 is quite stable,
presenting all related interface information of cpp .h.

I will continue to make it available in p5. And myself do have a plan to
introduce them in p6. It will be nice if someone can do so in parallel with
me (I mean, for p6). Since: 1. my knowledge on p6 sucks ;-) 2. currently
I haven't got enough time.

PS: It is very glad to see such information, really. In my opinion p6 indeed

needs trying to draw as many connections as possible with other
outstanding tool/project outside perl world. KDE is such a place too.

PS2: my project page:
   http://code.google.com/p/dongxu/wiki/QTEDI
   http://code.google.com/p/dongxu/wiki/PerlQT

-- Forwarded message --
From: Jesse Vincent [EMAIL PROTECTED]
Date: Mar 22, 2007 11:04 AM
Subject: Perl 6 Microgrants. Now accepting proposals.
To: perl6-internals@perl.org, perl6-language@perl.org,
perl6-compiler@perl.org, perl5-porters@perl.org

I'm pleased to announce the inaugural Perl 6 Microgrants program.
Best Practical Solutions (my company) has donated USD5,000 to The
Perl Foundation to help support Perl 6 Development.  Leon Brocard,
representing The Perl Foundation's grants committee, will work with
me to select proposals and evaluate project success.  We'll be making
USD500 grants to worthy Perl 6 related efforts. We're hoping to fund
a range of Perl 6-related projects over the life of the grant
program.  Accepted grants might be for coding, documentation, testing
or even writing articles about Perl 6. The program isn't tied to any
one implementation of Perl 6 -- We're interested in seeing proposals
related to Pugs, Perl 6 on Parrot, Perl 6 on Perl 5 or any other Perl
6 implementation.  Generally, we're interested in seeing projects
that can be completed in 4-6 calendar weeks.

Submitting a grant proposal
---

To submit a grant proposal, please email us at perl6-
[EMAIL PROTECTED] with the following information:

* A two to three paragraph summary of the work you intend to do
* A quick bio - Who are you? Is there opensource work you've done
that we should have a look at?
* A brief description of what success will mean for your project -
How will we know you're done?
* Where (if anywhere) you've discussed your project in the past
* Where you'll be blogging about your progress. (Twice-weekly blog
posts are a requirement for getting your grant money)

We'll be accepting proposals on a rolling schedule. We expect to pay
out these first 10 grants over the course of the summer. Depending on
how things go, we'll then either find more money for more grant
programs or we'll wind up the program and move on to other endeavors.

We're really excited to get rolling. Submit your proposals early and
often. Don't let somebody else beat you to the punch ;)

Best,

Jesse



--
Cheers, Dongxu
__END__
http://search.cpan.org/~dongxu


PGP.sig
Description: PGP signature


Re: Perl 6 Microgrants. Now accepting proposals.

2007-03-22 Thread Dongxu Ma

Hi all,

I am recently working on the QT4/KDE4 bindings for p5.
First cpp headers are parsed by a grammar based on Parse::RecDescent,
The production of latest dev release Parse-QTEDI-0.02_01 is quite stable,
presenting all related interface information of cpp .h.

I will continue to make it available in p5. And myself do have a plan to
introduce them in p6. It will be nice if someone can do so in parallel with
me (I mean, for p6). Since: 1. my knowledge on p6 sucks ;-) 2. currently
I haven't got enough time.

PS: It is very glad to see such information, really. In my opinion p6 indeed

needs trying to draw as many connections as possible with other
outstanding tool/project outside perl world. KDE is such a place too.

PS2: my project page:
   http://code.google.com/p/dongxu/wiki/QTEDI
   http://code.google.com/p/dongxu/wiki/PerlQT

-- Forwarded message --
From: Jesse Vincent [EMAIL PROTECTED]
Date: Mar 22, 2007 11:04 AM
Subject: Perl 6 Microgrants. Now accepting proposals.
To: perl6-internals@perl.org, perl6-language@perl.org,
perl6-compiler@perl.org, perl5-porters@perl.org

I'm pleased to announce the inaugural Perl 6 Microgrants program.
Best Practical Solutions (my company) has donated USD5,000 to The
Perl Foundation to help support Perl 6 Development.  Leon Brocard,
representing The Perl Foundation's grants committee, will work with
me to select proposals and evaluate project success.  We'll be making
USD500 grants to worthy Perl 6 related efforts. We're hoping to fund
a range of Perl 6-related projects over the life of the grant
program.  Accepted grants might be for coding, documentation, testing
or even writing articles about Perl 6. The program isn't tied to any
one implementation of Perl 6 -- We're interested in seeing proposals
related to Pugs, Perl 6 on Parrot, Perl 6 on Perl 5 or any other Perl
6 implementation.  Generally, we're interested in seeing projects
that can be completed in 4-6 calendar weeks.

Submitting a grant proposal
---

To submit a grant proposal, please email us at perl6-
[EMAIL PROTECTED] with the following information:

* A two to three paragraph summary of the work you intend to do
* A quick bio - Who are you? Is there opensource work you've done
that we should have a look at?
* A brief description of what success will mean for your project -
How will we know you're done?
* Where (if anywhere) you've discussed your project in the past
* Where you'll be blogging about your progress. (Twice-weekly blog
posts are a requirement for getting your grant money)

We'll be accepting proposals on a rolling schedule. We expect to pay
out these first 10 grants over the course of the summer. Depending on
how things go, we'll then either find more money for more grant
programs or we'll wind up the program and move on to other endeavors.

We're really excited to get rolling. Submit your proposals early and
often. Don't let somebody else beat you to the punch ;)

Best,

Jesse



--
Cheers, Dongxu
__END__
http://search.cpan.org/~dongxu


PGP.sig
Description: PGP signature


script binding for reiserfs?

2006-04-06 Thread Dongxu Ma
Hi all,As reiserfs more and more popular, is there any binding package for use in script languages? I did a search on Google and nothing found.Curently I am thinking about writing a binding for Perl, which can offer:
1) script-level operation against reiserfs2) DBI  DBD for reiserfs binding to treat the fs as a database. My aim is constructing a mid-and-small wiki directly on reiserfs without employing any real database
However, after some seeking on source. I got several issues:1) is there any so-called official userspace api exported? On gentoo there is a package named progsreiserfs introducing an api set under /usr/include/reiserfs, but I am not very sure if it is stable and the project is still alive.
2) regarding reiser3, where could I start to port? since exporting something in kernelspace is quite risky. Any advice and hint?-- Cheers, Dongxu__END__
dongxu.wordpress.comsearch.cpan.org/~dongxu


how to deal with static c++ object

2005-09-13 Thread Dongxu Ma
Hi all,

In some case, a class will have a static object for special purpose. For 
instance:
static foo foo::bar
I want to port this object to perl by wrapping it as a sub like this:
foo * 
foo::bar()
CODE:
RETVAL = (foo::bar);
OUTPUT:
RETVAL

This will always cause a segfault while invoking the sub in perl script.
Does anyone know the reason?

Another question, is there any better way to port a class method which 
returns 
an object. Like this:
foo foo::bar2()
since the returned object is local, which is usually allocated on stack, I 
have to 
new an object on heap and copy the content from the local one in my perlxs 
code. Is there a better way to handle this case?

Great thanks.
-- 
Bst Rgrs, Dongxu


how to specify namespace in perlxs

2005-09-07 Thread Dongxu Ma
Hi all,

Does any one know why I can't add 'using namespace brabra;' in .xs file? The 
xsubpp can't recognize while generating the .c file.

-- 
Bst Rgrs, Dongxu


Re: segfault while DELETE THIS

2005-08-18 Thread Dongxu Ma
Yes, you are right. I should dereference first. But now, the issue is,
who can explain why the wrong code could also invoke class' public
method via THIS-print() successfully.

_wrong code_ : $var = ($type) SvIV($arg);

On 8/17/05, Nicholas Clark [EMAIL PROTECTED] wrote:
 On Thu, Aug 11, 2005 at 11:55:49AM +0800, Dongxu Ma wrote:
 
  According to typemap in ExtUtils and perl.h, casting IV to pointer
  should be safe in this case, since on my machine(32bit, kernel
  2.6.12), sizeof(int) == 4, which is the same as a  pointer. Does
  anyone have any idea about this issue?
 
 I think that there's a bug in the typemap you're using:
 
  -typemap---
  TYPEMAP
  Test *T_OBJECT
 
  
  INPUT
  T_OBJECT
if(sv_isa($arg, \Test\)  sv_isobject($arg)) {
$var = INT2PTR($type, SvIV($arg));
 
   SvIV(SvRV($arg))
} else {
warn(\$arg is not a blessed object\);
XSRETURN_UNDEF;
}
 
 
 If I make the above change to use SvRV then I can avoid getting a segfault.
 
 Nicholas Clark
 


-- 
Bst Rgrs, Dongxu


segfault while DELETE THIS

2005-08-11 Thread Dongxu Ma
Hi All,

I am learning how to use XS (C). 
Firstly, I wrote a simple C++ class, compiled to libtest.so. A simple
main proved the test lib works fine.
test.h---
#ifndef _TEST_H
#define _TEST_H
class Test 
{
  public:
Test();
~Test();
void print(void);
  private:
int i;
};
#endif
--
test.cpp---
#include test.h
#include iostream.h

Test::Test()
{
i = 1;
coutnew inst createdendl;
}

Test::~Test()
{
coutinst destroyedendl;
}

void
Test::print(void)
{
couti =  this-i  endl;
coutTest::print calledendl;
}
---

Then, I wrote XS stuff and a test perl script(refer to below). The
script got a segfault while invoking `delete this' in c++ code.
Besides, the initial value of member variable i missed also.
-- output of `./test.plx ---
[EMAIL PROTECTED] ~/tmp/Test $ ./test.plx 
new inst created
i = 136090952
Test::print called
inst destroyed
Segmentation fault
---

I checked memleak via valgrind:
-- output of `valgrind --leak-check=yes test.plx' --
[EMAIL PROTECTED] ~/tmp/Test $ valgrind --leak-check=yes test.plx 
==31931== Memcheck, a memory error detector for x86-linux.
==31931== Copyright (C) 2002-2005, and GNU GPL'd, by Julian Seward et al.
==31931== Using valgrind-2.4.0, a program supervision framework for x86-linux.
==31931== Copyright (C) 2000-2005, and GNU GPL'd, by Julian Seward et al.
==31931== For more details, rerun with: -v
==31931== 
new inst created
i = 464868768
Test::print called
inst destroyed
==31931== Invalid free() / delete / delete[]
==31931==at 0x1B905A4E: operator delete(void*) (in
/usr/lib/valgrind/vgpreload_memcheck.so)
==31931==by 0x1BEE0229: XS_Test_DESTROY(interpreter*, cv*) (Test.c:52)
==31931==  Address 0x1BACBDE4 is 756 bytes inside a block of size 4080 alloc'd
==31931==at 0x1B9052F4: malloc (in /usr/lib/valgrind/vgpreload_memcheck.so)
==31931==by 0x80D3291: Perl_safesysmalloc (in /usr/bin/perl5.8.7)
==31931== 
==31931== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 41 from 2)
==31931== malloc/free: in use at exit: 753961 bytes in 12648 blocks.
==31931== malloc/free: 24174 allocs, 11527 frees, 1316185 bytes allocated.
==31931== For counts of detected errors, rerun with: -v
==31931== searching for pointers to 12648 not-freed blocks.
==31931== checked 1114300 bytes.
==31931== 
==31931== 
==31931== 5 bytes in 1 blocks are definitely lost in loss record 2 of 21
==31931==at 0x1B9052F4: malloc (in /usr/lib/valgrind/vgpreload_memcheck.so)
==31931==by 0x80D46CE: Perl_savesharedpv (in /usr/bin/perl5.8.7)
==31931== 
==31931== 
==31931== 192 bytes in 1 blocks are definitely lost in loss record 11 of 21
==31931==at 0x1B905DFB: realloc (in /usr/lib/valgrind/vgpreload_memcheck.so)
==31931==by 0x80D3424: Perl_safesysrealloc (in /usr/bin/perl5.8.7)
==31931== 
==31931== 
==31931== 14709 (1991 direct, 12718 indirect) bytes in 14 blocks are
definitely lost in loss record 14 of 21
==31931==at 0x1B9052F4: malloc (in /usr/lib/valgrind/vgpreload_memcheck.so)
==31931==by 0x80D3291: Perl_safesysmalloc (in /usr/bin/perl5.8.7)
==31931== 
==31931== 
==31931== 6160 bytes in 1 blocks are possibly lost in loss record 17 of 21
==31931==at 0x1B905DFB: realloc (in /usr/lib/valgrind/vgpreload_memcheck.so)
==31931==by 0x80D3424: Perl_safesysrealloc (in /usr/bin/perl5.8.7)
==31931== 
==31931== 
==31931== 181636 bytes in 14 blocks are possibly lost in loss record 20 of 21
==31931==at 0x1B9052F4: malloc (in /usr/lib/valgrind/vgpreload_memcheck.so)
==31931==by 0x80D3291: Perl_safesysmalloc (in /usr/bin/perl5.8.7)
==31931== 
==31931== LEAK SUMMARY:
==31931==definitely lost: 2188 bytes in 16 blocks.
==31931==indirectly lost: 12718 bytes in 80 blocks.
==31931==  possibly lost: 187796 bytes in 15 blocks.
==31931==still reachable: 551259 bytes in 12537 blocks.
==31931== suppressed: 0 bytes in 0 blocks.
==31931== Reachable blocks (those to which a pointer was found) are not shown.
==31931== To see them, rerun with: --show-reachable=yes
---

According to typemap in ExtUtils and perl.h, casting IV to pointer
should be safe in this case, since on my machine(32bit, kernel
2.6.12), sizeof(int) == 4, which is the same as a  pointer. Does
anyone have any idea about this issue?

Refer to XS source below:
-- Test.xs ---
#include EXTERN.h
#include perl.h
#include XSUB.h
#include ppport.h

#include clib/test.h
#include stdio.h

MODULE = Test   PACKAGE = Test  

Test *
Test::new()

void
Test::DESTROY()

NO_OUTPUT void
Test::print()