perl6 taint other traits
Hi, In Perl5 there can be a flag on a variable, that shows, if it's tainted or not. I would like you to ask, if it will be possible the same with Perl 6, or - and I'm most interested in this -, if it's possible to create something like this by me (defining meta information on variables, that not just stored, but has some effect)? And, maybe it's the same question, is it possible to declare traits/properties on a variable, or I just can use the ones that declared by the language (and I've misunderstood the conception)? Bye, Andras
embedding languages in Perl 6
Hi, I'm just wondering, if the following would be possible with Perl 6 or not? XML $a=elemselemContent #1/elemelemContent #2/elem/elems; say $a.elems[0].elem[1].content; # Content #1 for ($a.elems) { say $_.content; } or XPath like syntax on a structure? SQL $a=select * from table; for(select * from table where id5) { say $_.id ~ ' - ' $_.value; } The ideas coming from Comega, the next version of CSharp(?). Here's an intro about it: http://www.xml.com/pub/a/2005/01/12/comega.html?page=2 Or just search for comega with you favourite search engine. The first one, creating native XML support for a language is not new, E4X (EcmaScript for XML) is about the same: http://www.ecma-international.org/publications/standards/Ecma-357.htm I think both about macros, and it seem's it will be possible extend Perl 6 with them. But what do you think about extending Perl 6 (or Perl 6.1) with native XML handling, like it's native regular expression / rule handling? Bye, Andras
Re: embedding languages in Perl 6
Hi, : I'm just wondering, if the following would be possible with Perl 6 or not? : : XML : : $a=elemselemContent #1/elemelemContent #2/elem/elems; : : say $a.elems[0].elem[1].content; # Content #1 : : for ($a.elems) { say $_.content; } : : or XPath like syntax on a structure? That's somewhat ambiguous with our current qw// notoation. Yes, I've realized it. One of the reason of my mail was this. : SQL : : $a=select * from table; : for(select * from table where id5) { : say $_.id ~ ' - ' $_.value; : } That one would be pretty easy to do with a select macro, if you could figure out how to terminate the SQL parse. It ends, when a non opened ')', a ';' or a '}' is coming. Of course, that's not all cases, but it seems to be not so hard to find the all possible cases. : The ideas coming from Comega, the next version of CSharp(?). Here's an : intro about it: : : http://www.xml.com/pub/a/2005/01/12/comega.html?page=2 : : Or just search for comega with you favourite search engine. : : The first one, creating native XML support for a language is not new, : E4X (EcmaScript for XML) is about the same: : : http://www.ecma-international.org/publications/standards/Ecma-357.htm : : I think both about macros, and it seem's it will be possible extend Perl : 6 with them. But what do you think about extending Perl 6 (or Perl 6.1) : with native XML handling, like it's native regular expression / rule : handling? Let me note, that E4X is not just about declaring, but processing, too. We should avoid installing fads or domain-specific sublanguages into Standard Perl 6, but it's easy enough to change the language with a single use or macro. I see that doing select is trivial and doesn't impact anything in Standard Perl 6, since Perl 5's select() is likely going away anyway. I'm not sure, if XML is more domain specific than regexp or not. I think it's somewhere related to text processing as much as regexpes. It's a little harder to sneak foo.../foo into the language since we have foo to mean qw/foo/ as a term. Perhaps this is indicating that we should reserve a character for introducing user-defined terms. I suppose the logical candidate for that is ` these days, since pretty much everything else in ASCII land is taken. So you could write a macro on ` that treats the next thing as a self-terminating construct. (That is, no terminating ` is required, though the default `...` could still parse to mean q:x/.../, I suppose. You'd lose that if you redefine term:` to something else, but no big loss, unlike foo.) Anyway, you'd get things like: $a=`elemselemContent #1/elemelemContent #2/elem/elems; I don't like it. I've learned at Perl 5 and in other languages, that ` need a closing `. It would be nicer to say: $a=xmlelemselemContent #1/elemelemContent #2/elem/elems; But native xml parsing is better, I think. :) $a=`select * from table`; It looks better, but I think ` isn't needed for it. Anyway, I agree, that SQL is a more domain specific language, that it should come from a module - at least you have to give for initialization somewhere the server address, the user and the password (or other connection parameters), so it's better to do it at with a setup sub. Anyway, it's possible to write: $a=sqlselect * from table; I've gone ahead and terminated the sql variant like a quote construct just to clarify the end of it, since SQL is not so obviously self-terminating as XML is. If MS Comega and E4X can do it, I think Perl 6 could do it easily, too. ;) You could not, of course, have both of those unless you did lookahead to see if the next thing was or select. Hmm, maybe that should be standard behavior for user-defined ` extensions. If the actual I agree, except the notation. Bye, Andras
Re: Fwd: Re: embedding languages in Perl 6
Hi, What is the benefit of this syntax over having a simple function that takes one argument, interpolating variables from CALLER::? for sql 'SELECT * FROM table WHERE id=$id' { ... } The difference is between compile time parsing and runtime parsing. This expression can be transformed to a prepare statement plus a call, which is not just faster, but more safer, if $id contains aposthropes or other characters. Maybe other abstraction would be possible, too. What about this (I'm not really sure, if it's ok): INSERT INTO table (col1, col2) VALUES %row; And it will be: INSERT INTO table (col1, col2) VALUES (?,?) and %row.col1, %row.col2 will be insert as values. Bye, Andras
Re: Perl development server
Hi, I'd like one. Sure - just think of a nice catchy username! :) I'd like another one, as boogie. I think now, that I will use it, but I have a lot of jobs these days, with higher priorities :( than Perl6. dev.pugscode.org seems indicated ... Sorry, but 'dev' isn't cute enough :). And it's going to be something.perl6.nl, probably. I don't mind aliases, though, but they better be CNAMEs. I can offer a subdomain of perl6.hu, too - as a CNAME. ;) I think, the cute name can be about animals. A camel and a parrot are in my mind. Or what about camelseeks.org/perlseeks.org? It sounds like camel6 and perl6. Bye, Andras
Re: Hackathon users (was: Perl development server)
Hi, Thomas Klausner skribis 2005-05-23 18:03 (+0200): While I will inform everyone what they need, I'm sure quite a lot people will show up without a fresh checkout of the various repositories. So if I can get a number of dummy accounts (to be deleted after the event) that would be great! hackathon1..hackathon9, or do you need more? BTW, will all users on this machine share one svn working copy or is everyone supposed to to his/her own checkout? Or is this one of the things someone should organise? There may be a local mirror to minimize bandwidth (if someone arranges this to happen), but every uses should have their own working copy, because otherwise versioning systems don't work too well: you would be committing someone else's changes, for which you don't know a good log entry, and the logs no longer show the correct user names. I think that, for hacking there's no need for users on a remote machine, if the hackers has a computer, they can develop locally, has a repo locally. Or if you can offer computers locally, you can install an environment for them (or maybe you would like to take out these installs with this server?). If there will be new projects starting there, then it would be nice to share them with a server for other people, to get it after the conference, and join. But it needs an SVN server, at least, and an easy to setup plain project site skeleton. I think it would be nice, if somebody can prepare these tools for both Hackathon, and for other people as well. Bye, Andras
Re: Perl development server
Hi, I think, the cute name can be about animals. A camel and a parrot are in my mind. Parrot can't be, because that's also the name of one of the projects, and I want to avoid confusion. I just thinking something related these animals, not the animal. Maybe feather, etc. It's not the big idea itself. ;) Camel -- sorry, but years of Perl still haven't convinced me they are cute animals :) Besides, it feels wrong to see a camel in Perl context without the text used with permission. (Even though that is only required with images) I have no these thoughts about camel, but it's your decision. However, I like onion, what Thomas recommended. Or what about camelseeks.org/perlseeks.org? It sounds like camel6 and perl6. The domain already exists, but if you want to register additional domains, go right ahead. Ask me for DNS information later. You mean, that you would like to create a subdomain for perl6.nl? Bye, Andrs
Re: Perl development server
Hi, Just to know, onion in Hungarian is hagyma. ;) Bye, Andras On Tue, 24 May 2005, wolverian wrote: On Tue, May 24, 2005 at 12:12:57PM +0200, Juerd wrote: I'm currently considering 'ui', which is Dutch for 'onion'. I bet almost nobody here knows how to pronounce ui ;) That reads 'user interface' to me, which I think isn't what we want. How about 'sipuli'? That's what onion is called in Finnish. :) Anyway, I do think the name should be English, to be as accessible as possible. 'Feather' is nice, and reminds me of Pugs's origins. On the other hand, maybe 'falcon' (as terribly cliched as it is) is more accurate of Pugs nowadays. -- wolverian
Re: reduce metaoperator on an empty list
Hi, You have to either supply an initial value or refactor your logic not to allow an empty @array (as in the first case). If you want it some other way, there are far too many special cases we have to work with, some of which are just mathematically impossible. I think `fail`ing is the best bet. I haven't read the whole thread, so I'm sorry, if it was before. I think that a fail is a good idea. Or maybe it should be a warning, and the return value should be undef. I mean: [[EMAIL PROTECTED] === undef undef; [EMAIL PROTECTED] === undef * undef; etc. Bye, Andras
My presentation on last weekend
Hi, I just would like to share it with you. We had a weekend at the lake Balaton on the last weekend, where I had a talk about Perl 6. The guys liked it (the girls had sunbath during the event :), and one of them (Poetro) said the summary: then we can say, that Perl 6 is an operator oriented language? We agreed. Bye, Andras
using rules
Hi, I'm working on a web templating system, and I'm wondering how should I use rules? I have these defs: rule elem { \ wts \: ([a..z]+) \/ \ } rule block { \ wts \: ([a..z]+)\(.*?)\ \/ wts \: $1 \ } I would like to execute subroutines during the evaluation. What should I do? Is the following the right way? given $template { s/block/{trigger_block()}/; s/elem/{trigger_elem()}/; } How can I catch the matched elem name, and block content? I'm guessing that hypotetical variables can be the solution, but it says, that those variables should have been defined, before I use them, and it's not that case. Bye, Andras
flattening arguments
Hi, From the Perl6 and Parrot Essentials: - 8 - sub flat_hash ($first, $second) { say first: $first; say sec. : $second; } my %hash = (first = 1, second = 2); flat_hash(*%hash); - 8 - It says, that No compatible subroutine found. I've modyfied the subroutine: - 8 - sub flat_hash (+$first, +$second) { say first: $first; say sec. : $second; } - 8 - Now, I got: first: first 1 second 2 sec. : - I've tried it on the feather.perl6.nl machine, with pugs. Is it the right behaviour? Bye, Andrs
Re: using rules
Hi, No ideas? Bye, Andras I'm working on a web templating system, and I'm wondering how should I use rules? I have these defs: rule elem { \ wts \: ([a..z]+) \/ \ } rule block { \ wts \: ([a..z]+)\(.*?)\ \/ wts \: $1 \ } I would like to execute subroutines during the evaluation. What should I do? Is the following the right way? given $template { s/block/{trigger_block()}/; s/elem/{trigger_elem()}/; } How can I catch the matched elem name, and block content? I'm guessing that hypotetical variables can be the solution, but it says, that those variables should have been defined, before I use them, and it's not that case.
Re: using rules
Hi, I'll take a shot at it since no one else seems to want to. :-) Hope this is helpful. Corrections are welcome from anyone who spots any mistakes. Thanks, it helped me! More questions. ;) It seems to me, that the following constructs not yet(?) implemented in Pugs. Is it true? Built-in rules: sp alpha etc. Rule modifiers (:i modifier after the name of the rule): rule xxx :i { anything } It works well w/o :i. Bye, Andras
PGE error?
Hi, I don't know what happens and where in the code, but... Anyway, it's strange... I have this code and input.tpl: --- 8 --- rule sp { [ ] } rule id { [a..z][a..z0..9]+ } sub do($match) { say $match[0]; return +; } my $template=slurp('input.tpl'); $template ~~ s:g! [ \ server \: (id) [sp+ $?id:=(id) sp*=sp*(-[]*)]* sp* \ (.*?) \\/ server \: $0 \ ] | [ \ server \: (id) [sp+(id)sp*=sp*(-[]*)]* sp* \/\ ] !{ do($/) }!; say $template; --- 8 --- text server:foo / server:huh / text server:boo inside server:huh / inside /server:boo text --- 8 --- Running it several times, one time works: matches and replaces / things to +-es, one time it not works... Randomly. Where should I send these kind of bugs? Bye, Andras
proposal: binding with a function
Hi, As I know, for binding, you can use the := operator, and just this: $a := $b; I would like to make a proposal, based on Ruby[1]: alias $a, $b; It's a fun: sub newline { \n x $_; } alias newlines, newline; So you can write: print 5.enters; Currently, you have to write it a more uglier way: my newlines := newline; Anyway, char '' is really neccesary there? It should work w/o it, too, as I think. Now - in Pugs - it doesn't. Bye, Andras [1] http://www.zenspider.com/Languages/Ruby/QuickRef.html#29
new mailing list: perl6-general?
Hi, I would have some general Perl6 programming questions. Where should I ask them? It's not about language design, not about compiling/compilers and even not related to the internals. As more and more people will start hacking Perl6, I think, that it would be useful to having a list for this. In this particular case, I would like to ask about creating a langugage construct (maybe there's a desgin pattern for it, maybe not) for a web templating system can be expanded by the user. Bye, Andras
Re: new mailing list: perl6-general?
Hi, So, that leaves either perl6-language or a new list. Personally I could see it going either way -- even though general Perl6 programming questions aren't directly about language design, it may still be useful to language designers to see the types of questions that people are asking and to see how well the language design can work in practice. Or maybe that's not needed. But I tend to lean away from list proliferation where possible. So, I'd suggest putting general questions about Perl 6 on perl6-language. In saying this, however, I think it's important to try to distinguish questions about Perl 6 from questions about the various implementing components such as Pugs, PGE, and any forthcoming Perl 6 compiler(s). For some time these implementations will be only approximations of the Perl 6 language design, so they're not authoritative as far as testing understanding of Perl 6. (But they are often very illustrative and educational. :-) So, questions like XYZ doesn't seem to work in Pugs or PGE probably belong on perl6-compiler. Where should I ask, that what's PGE means? Yes, I know, it's Parrot Grammar Engine, and I know what it is, but a beginnner maybe not. And I think that there are a lot of questions around like this, but people feel, that those questions don't fit to the lists. Or maybe not, don't know. I agree, that it is useful for the designers to see the questions, but if it will be a separate list, it still won't be impossible for them. Anyway, I understand why you wrote what you wrote, so as there will be no decision, I'll ask my questions on perl6-compiler. Bye, Andras
Re: new mailing list: perl6-general?
Hi, Anyway, I understand why you wrote what you wrote, so as there will be no decision, I'll ask my questions on perl6-compiler. I mean, perl6-language. Bye, Andras
Creating a web templating engine
Hi, I'm busy with creating a widget based web templating engine, but I have some problems, please help me. The engine would allow you to define widgets, and use those in your templates. I would like it to be an OO module. In the template, you can write this: server:input id=name width=100px maxlength=64 important=yes / When the template engine read it, it will call a subroutine: call_a_sub_for_input(id='name', width='100px', maxlength='64', important='yes'); What this sub gives back, will be put into the output. I hope, you got the idea. I have the code, that can parse the template, and the code, that would call the widget, so no problems with it. I don't know, how to put it together. I don't know, how should the programmer define a new widget, how it would be the most nicer way? How it can be detected by the template engine? I don't want a register function, like this: $wte = new WTE; $wte.register('input', my_input_widget); I don't prefer it, to be 20-30 register line in my programs, that does nothing, just register. It would be OK, to just define a global subroutine, and allow the template engine to call widget_$name if it reads a widget, but... sub widget_input(*%params) { ... } It's not nice. Maybe something like this? new_widget :input = { return input /; } It's almost a register function, but it's more compact, and I like it. But if I would like to get parameters from the widget caller, how can I manage it? Is it possible to call this new noname sub with parameters, and get it easily inside the sub, for example like this:? new_widget :input = { my $name = _something_{'id'}; return 'input name=' ~ $name ~ ' /'; } And I have more questions, but that's enough for this mail. Did you got my problem? Bye, Andras
Re: Creating a web templating engine
Hi, $wte = new WTE; $wte.register('input', my_input_widget); I don't prefer it, to be 20-30 register line in my programs, that does nothing, just register. maybe something like this? class MyWTE is WTE { method input (...) {...} method some_other_thing_you_would_have_had_to_register (...) {...} ...; } And how the WTE class will be able to call these methods? new_widget :input = { my $name = _something_{'id'}; return 'input name=' ~ $name ~ ' /'; } new_widget :input = - Str $id { return 'input name=' ~ $id ~ ' /'; }; # or new_widget :input = sub (Str $id) { return 'input name=' ~ $id ~ ' /'; } Hmm. It's still good, isn't it? new_widget :input = sub($id) { ... } I think I like it. :) I would choose a bit more compact form if it's possible (I think, it isn't) - so if somebody has any idea, please let me know. :) But it's quite OK. Thanks, Andras
Re: proposal: binding with a function
Larry, You can always write a macro that does that. [...] That won't work on a method name anyway unless you do it in the dispatch class. [...] You'll have to write your own macro if you want to do that. As I understood, you wrote down, how I can workaround it with macros, and why it wouldn't work well. As I see, there's no a nice solution to alias a method or a sub, even with macros. But you didn't wrote, why are you against the 'alias'? Bye, Andras
Re: proposal: binding with a function
Hi, Carl Franks wrote: : alias newlines, newline; Isn't it possible to add a Role to the relevant Class, which specifies that is 'handles' the method name you want as an alias? If it's possible, it would be fine for me in this particular case. Is it possible? Anyway, IMHO this alias function can be useful in other cases, too. Bye, Andras
Re: new mailing list: perl6-general?
Hi Michele, Where should I ask, that what's PGE means? Yes, I know, it's Parrot Grammar Engine, and I know what it is, but a beginnner maybe not. And I think that Which makes me think that first or later it may be worth to start a FAQ for questions like these even if they're not frequently asked. And indeed a perl6-general may be a starting point for writing one. I agree. Is it possible the setup an SVN repo for the FAQ, that would be mirrored the the web page? Anyway, if the perl.org webmasters not interested in it, or it is a big work to setup a mailing list and/or a FAQ like this, I can offer the infrastructure for it, and I can setup it in a day. Bye, Andras
Re: new mailing list: perl6-general?
Hi, I think, that David's version is matches with my opinion. I don't think, that beginners would be a better name for it, but maybe more practical, as it's a more evident name. Bye, Andras David Storrs wrote: On Jun 15, 2005, at 3:33 PM, Patrick R. Michaud wrote: And here they are... this is just a draft -- feel free to flame/edit/ tear it apart liberally. These are also written assuming we don't create a perl6-general list (but it shouldn't be hard to adapt them should one be created). Well, I'd suggest the following. (Anything not mentioned stays as you wrote it.) perl6-language This is the theory of list. Discussion of the design of the perl6 language, and its desired (or unwanted) feature list. If you have patches and/or suggestions for improving the Perl 6 design documents (Apocalypses, Synopses, etc.), send them here. perl6-howto This is the practice of list. Come here to ask How do I..., What does XYZ mean?, or Why doesn't this work? Novices are especially welcome. (Note: I envision this list being much like beginners@perl.org, but I never liked that name because it seems like it would drive away those who have a question but do not consider themselves beginners. On the other hand, maybe it's more important to explicitly welcome novices. I could go either way: maybe the above list should be 'perl6-beginners')
Re: new mailing list: perl6-general?
Hi, Fagyal Csongor wrote: I think, that David's version is matches with my opinion. I don't think, that beginners would be a better name for it, but maybe more practical, as it's a more evident name. Hmmm, I think beginner is a little negative. What about professional Perl5 programmers, who wish to learn Perl6? Wouldn't like the name :-)) How about 'perl6-usage', 'perl6-programming' or... hmmm, simply 'perl6'? I like perl6-programming, as it means, that it's ok to post there general programming questions (related to perl6), too. And maybe my original proposal, perl6-general is OK, too. Bye, Andras
Re: proposal: binding with a function
Hi, I'm still interested in, why alias wouldn't be a native Perl 6 term? I think, there are several reasons for alias: - in natural languages, synonims are very often - alias is a synonim - in Perl 6, currently there's no way to create a reference to a variable, _with the context of the variable_, too (binding just give me possibility to bind a variable into another, but the new variable won't be automatically have the same context, as the binded one) Some new examples, maybe better than before: sub kilobytes ($value:) is export { return $value*1024; } alias kilobytes, kilobyte; So both routines will be an exported one. You can use this code then: say 1.kilobyte; say 2.kilobytes; Bye, Andras BÁRTHÁZI András wrote: Larry, You can always write a macro that does that. [...] That won't work on a method name anyway unless you do it in the dispatch class. [...] You'll have to write your own macro if you want to do that. As I understood, you wrote down, how I can workaround it with macros, and why it wouldn't work well. As I see, there's no a nice solution to alias a method or a sub, even with macros. But you didn't wrote, why are you against the 'alias'? Bye, Andras
proposal: 404 method
Hi, Is there a way, to catch, if I call a method, that doesn't exists, to run a default one? I'm thinking about an error handler method. If not, I would like to propose this: class MyClass { method example ($self: $var) { say HELLO; } method default ($self: $method_name, %parameters) is method_not_found { say $method_name called; } } $mc = new MyClass; $mc.example(var) $mc.helloworld(var, var); -- and it outputs: HELLO helloworld called The above is maybe not the best (and not the most valid) syntax for my proposal, but I think you can get the idea. It would be very useful the hide parameters into the method name, like this: save_the_world(); save_the_captain(); And the default method will match the method name with /^save_the_(.*)$/, and saves $1. I hope, you will like it. As I know, it's not possible currently. Bye, Andras
Re: proposal: 404 method
Hi, Is there a way, to catch, if I call a method, that doesn't exists, to run a default one? I'm thinking about an error handler method. See all the AUTO subs. Cool! Where? Is it working currently with Pugs? Bye, Andras
Re: proposal: binding with a function
Hi, - in natural languages, synonims are very often - alias is a synonim Perl is modeled on natural languages, but that doesn't mean it is one. At its core, Perl is a limited, artificial language being explicitly designed with certain goals. One of those goals is that it should be as small as possible given the feature set we want it to support; an `alias` built-in that essentially duplicates an existing feature goes against that goal. I can agree with it, but I think it would be a great feature. And it doesn't depends on Perl 6, but it depends on Parrot, as I think. - in Perl 6, currently there's no way to create a reference to a variable, _with the context of the variable_, too (binding just give me possibility to bind a variable into another, but the new variable won't be automatically have the same context, as the binded one) I'm not sure what you mean by context here. Context has a very specific meaning in Perl, representing the type a function's caller is expecting; this doesn't seem to be what you're talking about here. alias kilobytes, kilobyte; This is a couple punctuation symbols short of: kilobytes := kilobyte; Or maybe: kilobytes ::= kilobyte; I'm not really sure what behavior you have in mind for alias. kilobytes := kilobyte; will not work for you (try it), because you have to declare the variable kilobytes - in the default strict mode. But you can't say for ex. my kilobytes, if you want to export it. I would like to copy if the subroutine/variable is local, or exported, or... etc. Oh, I have the term: I would like to copy the _scope_ of it, too. Forget the context. Simple binding shouldn't have to copy the scope, too. Anyway, alias is a Ruby term, and if Parrot will be able to support Ruby, then it will be able to support this function, too. Bye, Andras
Re: proposal: binding with a function
Hi, kilobytes := kilobyte; will not work for you (try it), because you have to declare the variable kilobytes - in the default strict mode. But you can't say for ex. my kilobytes, if you want to export it. So you say `our kilobytes ::= kilobyte` (or `:=`, you still haven't said if alias works at compile time or runtime) and call it a day. IIUC, traits like `is exported` are attached to the container, not the name; since aliasing connects a name to a container, you should be fine on that front. (If it doesn't work, that's because `is exported` does something funky that `alias` would have to treat as a special case; certainly other traits like `is rw` would follow a `:=`-binding.) Anyway, alias is a Ruby term, and if Parrot will be able to support Ruby, then it will be able to support this function, too. As I've said before, Perl supports `alias`--it's just spelled `:=`. If you're right, then I'm happy. I don't want alias, I would like to get it's behaviour. In Ruby, I think it's a compile time feature, but don't know, I'm not programming in Ruby. I'm not (yet) an expert in Perl 6, so sorry if I'm not right, but is exported is about the name, not the container, as I think. If you attach an is exported to a class method, you can reach it from everywhere, just using it's name. If you say _in your class_ that our mysub ::= exportedsub, then you can reach the mysub sub just in the class, not from everywhere in your program (as a plain sub). I'm really not sure, if I'm right, so please tell me, that I lost, and I will be happy. :) Bye, Andras
OO magic (at least for me)
Hi, I'm wondering, if it's possible with Perl 6 or not? class MyClass { method mymethod($par) { say mymethod called!; } } class ExClass is MyClass { mymethod(12); } # pugs myprog mymethod called! I would like to use mymethod to add ExClass some methods, etc. /// Just another problem, related to the above: class MyClass { method whenmother() { say MyClass is parent now!!!; say Her child name is: ~ ; } } class Child is MyClass { } # pugs myprog MyClass is parent now!!! Her child name is: Child Bye, Andras
Re: OO magic (at least for me)
Hi! I'm trying to answering my questions. Still interested in some official answer. :) --- 8 --- 8 --- 8 --- 8 --- 8 --- 8 --- 8 --- class MyMethod { method fun1() { fun2(); } method fun2() { say fun2!; } } class Child is MyMethod { } Child.fun1(); --- 8 --- 8 --- 8 --- 8 --- 8 --- 8 --- 8 --- *** No compatible subroutine found: fun2 I'm wondering why, but maybe, it's OK. --- 8 --- 8 --- 8 --- 8 --- 8 --- 8 --- 8 --- class MyMethod { method fun1() { fun2(); } sub fun2() { say fun2!; } } class Child is MyMethod { } Child.fun1(); --- 8 --- 8 --- 8 --- 8 --- 8 --- 8 --- 8 --- fun2! Sounds good. It seems to me, that I can call fun2() from inside MyMethod, from everywhere. OK, Child is MyMethod, so can I do it there too? No. :( --- 8 --- 8 --- 8 --- 8 --- 8 --- 8 --- 8 --- class MyMethod { method fun1() { fun2(); } sub fun2() { say fun2!; } } class Child is MyMethod { fun2(); } Child.fun1(); --- 8 --- 8 --- 8 --- 8 --- 8 --- 8 --- 8 --- *** No compatible subroutine found: fun2 The problem is calling fun2() from Child's declaration. As I think, the calling just happens at when interpreting the declaration of Child, but the scope is not Child's scope. Why? Let's try Child.fun2()! --- 8 --- 8 --- 8 --- 8 --- 8 --- 8 --- 8 --- class MyMethod { method fun1() { fun2(); } sub fun2() { say fun2!; } } class Child is MyMethod { Child.fun2(); } Child.fun1(); --- 8 --- 8 --- 8 --- 8 --- 8 --- 8 --- 8 --- fun2! Works well. Is it a not yet implemented feature in Pugs, or is by design? Still don't know, how can a method/sub automagically called, when I inherite a class. I would like to use the syntax you can see in my example #1, but the syntax of example #2 is still OK. I would like to use calling the classes own methods/subs when declaring a child, and calling a method/sub automatically, when I'm declaring a child. Bye, Andras
Re: OO magic (at least for me)
Hi, method fun1() { fun2(); } method fun2() { say fun2!; } *** No compatible subroutine found: fun2 fun2 is a method, not a sub. You need method syntax to call it: ./fun2; Hmm. It really works. :) I'm getting the idea, what's the difference between methods and subs. Anyway, my implementation is, that ./ means self's method - and the class is not an instance, so it has no self. ./fun2 still not working at the second class's declaration. IIRC, that's what submethods are for. Submethods aren't inherited. It is unclear to me whether subs are. Do you mean, that submethods for class methods (I don't know, if is it the official name of the non instance methods)? I don't think so. Bye, Andras