Re: The trouble with awesome

2012-05-28 Thread Xiao Yafeng
On Sat, May 26, 2012 at 6:34 PM, Nicholas Clark  wrote:

> On Fri, May 25, 2012 at 08:44:30AM -0500, B. Estrade wrote:
>
>
> Realistically, that's not going to happen. The internals of the Perl 5
> interpreter are not flexible enough to implement a lot of the features
> that
> Perl 6 has that Perl 5 does not.
>
> Nicholas Clark
>
> * Or Python 2 to Python 3, as far as I can tell as an outsider.
>


why can't we write a brand new perl5 interpreter or a better one based on
parrot VM if perl6's strength more than perl5 is just internals of the
interpreter?

it seems Gcc community had a similar discussion about mess of internal.
http://gcc.gnu.org/ml/gcc/2012-03/msg00263.html


Re: Rakudo Star - a useful, usable, "early adopter" distribution of Perl 6

2010-07-29 Thread Xiao Yafeng
Congratulations!

On Thu, Jul 29, 2010 at 8:23 PM, Patrick R. Michaud  wrote:
> On behalf of the Rakudo and Perl 6 development teams, I'm happy to
> announce the July 2010 release of "Rakudo Star", a useful and usable
> distribution of Perl 6.  The tarball for the July 2010 release is
> available from .
>
> Rakudo Star is aimed at "early adopters" of Perl 6.  We know that
> it still has some bugs, it is far slower than it ought to be, and
> there are some advanced pieces of the Perl 6 language specification
> that aren't implemented yet.  But Rakudo Perl 6 in its current form
> is also proving to be viable (and fun) for developing applications
> and exploring a great new language.  These "Star" releases are
> intended to make Perl 6 more widely available to programmers, grow
> the Perl 6 codebase, and gain additional end-user feedback about the
> Perl 6 language and Rakudo's implementation of it.
>
> In the Perl 6 world, we make a distinction between the language
> ("Perl 6") and specific implementations of the language such as
> "Rakudo Perl".  "Rakudo Star" is a distribution that includes
> release #31 of the Rakudo Perl 6 compiler [1], version 2.6.0 of
> the Parrot Virtual Machine [2], and various modules, documentation,
> and other resources collected from the Perl 6 community.  We
> plan to make Rakudo Star releases on a monthly schedule, with
> occasional special releases in response to important bugfixes or
> changes.
>
> Some of the many cool Perl 6 features that are available in this
> release of Rakudo Star:
>  * Perl 6 grammars and regexes
>  * formal parameter lists and signatures
>  * metaoperators
>  * gradual typing
>  * a powerful object model, including roles and classes
>  * lazy list evaluation
>  * multiple dispatch
>  * smart matching
>  * junctions and autothreading
>  * operator overloading (limited forms for now)
>  * introspection
>  * currying
>  * a rich library of builtin operators, functions, and types
>  * an interactive read-evaluation-print loop
>  * Unicode at the codepoint level
>  * resumable exceptions
>
> There are some key features of Perl 6 that Rakudo Star does not
> yet handle appropriately, although they will appear in upcoming
> releases.  Thus, we do not consider Rakudo Star to be a
> "Perl 6.0.0" or "1.0" release.  Some of the not-quite-there
> features include:
>  * nested package definitions
>  * binary objects, native types, pack and unpack
>  * typed arrays
>  * macros
>  * state variables
>  * threads and concurrency
>  * Unicode strings at levels other than codepoints
>  * pre and post constraints, and some other phasers
>  * interactive readline that understands Unicode
>  * backslash escapes in regex <[...]> character classes
>  * non-blocking I/O
>  * most of Synopsis 9
>  * perl6doc or pod manipulation tools
>
> In many places we've tried to make Rakudo smart enough to inform the
> programmer that a given feature isn't implemented, but there are
> many that we've missed.  Bug reports about missing and broken
> features are welcomed.
>
> See http://perl6.org/ for links to much more information about
> Perl 6, including documentation, example code, tutorials, reference
> materials, specification documents, and other supporting resources.
>
> Rakudo Star also bundles a number of modules; a partial list of
> the modules provided by this release include:
>  * Blizkost
>      - enables some Perl 5 modules to be used from within Rakudo Perl 6
>  * MiniDBI
>      - a simple database interface for Rakudo Perl 6
>  * Zavolaj
>      - call C library functions from Rakudo Perl 6
>  * SVG and SVG::Plot
>      - create scalable vector graphics
>  * HTTP::Daemon
>      - a simple HTTP server
>  * XML::Writer
>      - generate XML
>  * YAML
>      - dump Perl 6 objects as YAML
>  * Term::ANSIColor
>      - color screen output using ANSI escape sequences
>  * Test::Mock
>      - create mock objects and check what methods were called
>  * Math::Model
>      - describe and run mathematical models
>  * Config::INI
>      - parse and write configuration files
>  * File::Find
>      - find files in a given directory
>  * LWP::Simple
>      - fetch resources from the web
>
> These are not considered "core Perl 6 modules", and as module
> development for Perl 6 continues to mature, future releases
> of Rakudo Star will likely come bundled with a different set
> of modules. Deprecation policies for bundled modules will be
> created over time, and other Perl 6 distributions may choose
> different sets of modules or policies.  More information about
> Perl 6 modules can be found at http://modules.perl6.org/.
>
> Rakudo Star also contains a draft of a Perl 6 book -- see
>  in the release tarball.
>
> The development team thanks all of the contributors and sponsors
> for making Rakudo Star possible.  If you would like to contribute,
> see , ask on the perl6-compi...@perl.org
> mailing list, or join us on IRC #

Re: A new era for Temporal

2010-04-10 Thread Xiao Yafeng
Is Int a proper type? I hope I can use basic operation within Date and hours
in perl6 like:
  Date -1/24 + 1/24/60 + Date

On Fri, Apr 9, 2010 at 10:00 PM, Moritz Lenz  wrote:

> Am 09.04.2010 15:33, schrieb Dave Rolsky:
>
>  On Thu, 8 Apr 2010, Carl Mäsak wrote:
>>
>>  I do want to explicitly credit Dave Rolsky, whose work on the DateTime
>>> family of modules on CPAN has informed much of the current spec,
>>> sometimes to the point of verbatim copying.
>>>
>>
>> Thanks, but I'd hate to see you copy all my mistakes too!
>>
>> One thing I think is really important is to offer a Date-only object
>> without a time component.
>>
>> The lack of such an object in Perl 5's DateTime family is a real
>> problem. If you're only interested in dates and date math, time and time
>> zones just muddies the water.
>>
>
> I fully agree. I found Date::Simple on CPAN to do exactly what I want if I
> want date-only arithmetic. Here's a short summary:
>
> * Dates are constructed with today() or date('2010-04-09')
> * Operations: Date - Date => Int, Date + Int => Date, Date - Int => Date.
> Also ++ and -- are defined for Date objects. (In Perl 6 that would
> Date.succ, Date.pred)
> * Date objects can be queried for year, month, day, day of week (maybe day
> of year too, not sure)
> * Date objects stringify in the same format as accepted in the constructor.
>
> That's it.
>
> I hope to find the tuits to add such a type to the spec, and some
> additional constructors (like DateTime.Date or so).
>


Re: Is there a way to bulky feed?

2009-07-10 Thread Xiao Yafeng
On Fri, Jul 10, 2009 at 12:29 AM, yary  wrote:

>
>
> On Wed, Jul 8, 2009 at 8:45 PM, Xiao Yafeng  wrote:
>
>> Any thoughts?
>>
>
> First let's fix the whitespace in your post so it's easier to read-
>
> My question is: could I write below code in perl6:
>
> # 2 loops like for @a -> $b[0],$b[1] {;}
> my @a = <1 2 3 4>; my @b[2]; for @a ->@b {;}
>
> my @a = <1 2 3 4>; my @b; for @a -> @b{;}# 1 loop
>
> # 2 loops like grep {$^a+$^b >3} <== @a;
> my @a = <1 2 3 4>; my @b[2];
>   grep(@b){say 'yes' if +...@b>3} <== @a;
>
> # slurp
> my @a = <1 2 3 4>; grep{say 'yes' if +...@_>=10} <== @a;
>
> One style point, generally a list of numbers is written as
> my @a = 1..4; # list of numbers, <1 2 3 4> is a list of strings
> my @a = '1'..'4' # equivalent to <1 2 3 4>
>
> As for your original question, I am not quite sure what you're asking. Do
> you want a simpler way to write
> for 一..四 {say "$^x $^y";}
> 一 二
> 三 四
> (... which assumes that unicode sequencing is working, I can't test that on
> my machine!)
>
> Or do you want something like-
> for  -> $a {for  ->$b {say "$a $b"}}
>
> Or using more memory and less looping (at least superficially!)
> for 'a'..'d' X  {say "$^p $^q"};
>
> In other words, if you can write some code that runs and tell us how you'd
> like to simplify it, I might be able to answer better.
>

What I thought is reducing loop times.
In some case, we don't need pop a item from a list one by one. Acoording to
memory capacity of machine, we can get  more than  one items from the list.
for a simple example,
  for 1..100 -> $x {
func1($x) if $pid = fork;
   }
  above code will loop 100  times, fork 100
processes and waste most of memory on machine.
   if I can say,
my @b[1]; for 1..100 -> @b{
   func2(@b) if $pid = fork;
}
   IMHO, preceding code will be better in term of memory
utilization.


Is there a way to bulky feed?

2009-07-09 Thread Xiao Yafeng
My question is: could I write below code in perl6:
my @a = <1 2 3 4>; my @b[2]; for @a ->
@b {;} # 2 loops like for @a -> $b[0],$b[1]{;}
my @a = <1 2 3 4>; my @b; for @a -> @b
{;} # 1 loop
my @a = <1 2 3 4>; my @b[2];
grep(@b){say 'yes' if +...@b>3} <== @a;   # 2 loops like
grep {$^a+$^b >3} <== @a;
my @a = <1 2 3 4>; grep{say 'yes' if +...@_
>=10} <== @a;   # slurp

Since memory is cheaper and cheaper, bulky feed can maximize to make use of
memory and reduce loops.
Any thoughts?


Re: some questions about S02(type)

2009-04-05 Thread Xiao Yafeng
I don't think an array of hashes and a hash of arrays could perfectly
represent a Table type.
There are several important facts of a relational model:unordered
columns and tupples, various constraints on columns. E.g. how can we
represent multi-unique constraints as an array of hashes?


On 4/4/09, Timothy S. Nelson  wrote:
> On Sat, 4 Apr 2009, Xiao Yafeng wrote:
>
>>>> 3. Could I define primary key for a bag variable?
>>>
>>> All items in a Bag are "primary keys", but there's no data additional
>>> data associated with it.
>>
>> I mean whether I can see Set as a table  and Bag as a table with a
>> unique constraint? like:
>>subset test of Bag(test_name Str, test_ID Int, primary
>> key(test_ID))
>
>   I don't think you can really do something like that.  Perl 6 as
> specified leaves many things up to libraries.  Implementing a Table type
> will
> no doubt be one of those things.  I would like to have a Table type that
> will
> work well with the Tree/Plex type that I am working on.
>
>   In the meantime, a table would need to be represented as an array of
> hashes, or a hash of arrays.
>
>   HTH,
>
>
> -
> | Name: Tim Nelson | Because the Creator is,|
> | E-mail: wayl...@wayland.id.au| I am   |
> -
>
> BEGIN GEEK CODE BLOCK
> Version 3.12
> GCS d+++ s+: a- C++$ U+++$ P+++$ L+++ E- W+ N+ w--- V-
> PE(+) Y+>++ PGP->+++ R(+) !tv b++ DI D G+ e++> h! y-
> -END GEEK CODE BLOCK-
>
>


Re: some questions about S02(type)

2009-04-04 Thread Xiao Yafeng
On Fri, Apr 3, 2009 at 10:52 PM, Moritz Lenz  wrote:

> Xiao Yafeng wrote:
> > 1. Could I set multi-return type?like
> >  sub test as (Int, Str) {...}
>
> "as" is coercion - so to what would it coerce? Int or Str? How could the
> compiler know? Or do you mean something like a tuple?
>

   as what Timothy S. Nelson say


>
> > 2. set is unordered collection of values, subset is new type.  People are
> > apt to confuse the two concepts.
>
> Note that people never write "subset" in their code, the write things like
> sub f($x where { ... } )  and the  "where" constructs the subset type. I
> don' think that's
>

 I think subset can define a new type, I'm custom to set it at
head of code,
subset name_string of Str where {~~/^^name/};
 am I wrong?


>
> > 3. Could I define primary key for a bag variable?
>
> All items in a Bag are "primary keys", but there's no data additional
> data associated with it.
>

 I mean whether I can see Set as a table  and Bag as a table with a
unique constraint? like:
subset test of Bag(test_name Str, test_ID Int, primary key(test_ID))


some questions about S02(type)

2009-04-03 Thread Xiao Yafeng
1. Could I set multi-return type?like
 sub test as (Int, Str) {...}
 my  (Int, Str) sub test {...}
 or my (Int|Num, Str) sub test{...}

2. set is unordered collection of values, subset is new type.  People are
apt to confuse the two concepts.

3. Could I define primary key for a bag variable?


Re: File test ops as string methods

2008-11-08 Thread Xiao Yafeng
>
> I've been thinking about that.  One interesting ramification of
> the current matching rule is that you could say either of:
>
>"foo".io ~~ :r :x
>
> or
>
>"foo" ~~ :io(:r :x)
>
> where .io is whatever your "casting" method of choice is for turning
> a string into an object with the correct methods.  Somehow I think
> .filename is a bit too long, huffmanwise.


If io is casting method, which statement below is correct:

say ok if "1234".io > 1000;

or

say ok if "1234".int >1000;


operator vs function

2008-10-30 Thread Xiao Yafeng
Off the top of one's head, since there is no particular difference between
an operator and a function, can I see a function as a operator:

(1, 2, 3, 4) >>elems<<(2, 3, 4, 5)  #(2, 2, 2, 2)
(1, 2, 3, 4) >>shift<<(2, 3, 4, 5)  #(2, 3, 4, 5)

Moreover, can I see a subroutine as a operator:

(1, 2, 3, 4) >>{$a>$b??$a!!$b}<<(2, 3, 4, 5)#(2, 3, 4, 5)


Re: how much detail can I get from caller.want?

2008-08-31 Thread Xiao Yafeng
On Sat, Aug 30, 2008 at 4:22 AM, Dave Whipp <[EMAIL PROTECTED]> wrote:

> Lets say I want to find the 5th smallest element in an array. I might
> write:
>
>  @array.sort.[4];
>
> How does the implementation of the sort function know that I just want to
> 5th item (and thus choose an appropriate optimization)? Obviously the
> function could be told that it's caller wants 5 values in list context, but
> is there a way to get more info than that?
>


The second dot is superfluous since [] isn't a method. You should say:
@array.sort[4];


new method question

2008-08-22 Thread Xiao Yafeng
There are no barewords in Perl 6, but it seems new method is an exception:

class Dog {

has $name;
method bark () {
say $name;
}
}
my $p = Dog.new($name => 'boo');
  $p.bark;#error!
my $p = Dog.new( name => 'boo');
  $p.bark#say boo

more confused:

class Dog {

has @names;
method bark () {
say @names;
}
}
my $p = Dog.new(names => 'boo');
  $p.bark;#nothing but passed.

So, how set array attribute of a class by new method?


question on max | min op

2008-04-01 Thread Xiao Yafeng
I've read Synopsis and I wondered why to treat max and min as
operator. IMHO, view them as list functions is more reasonable. Like
below:

@test.max

is clearer than

@test[0] max @test[1]  or [max] @test.


Any reply would be really appreciated and will much help me learn
perl6. Thanks in advance!