Michael Schwern presents Method::Signatures, a module that allows defining Perl subroutines with function signatures in a syntax inspired by Perl 6. It works by rewriting the code at compile time using Devel::Declare rather than a source filter. Key features demonstrated include required and optional parameters, named and positional arguments, aliases, and more. While powerful, the module is still a work in progress, with debugging support and better error handling needing further work. The goal is to implement a "signatures" pragma for inclusion in Perl 5.
Simple Photo Processing and Web Display with PerlKent Cowgill
I have a small photo gallery on my website and in this presentation, I share
some steps I used in creating a nearly automatic workflow of getting
pictures from my camera to his gallery using Perl.
You might have heard of Domain-Driven Design. You may have heard DDD is a tool to write readable and change-ready code. You may have even heard DDD comes with a lot of talking, and modeling, and customers...
Starting with DDD sounds big, and scary, doesn't it?
But getting started is not scary. Come find out what DDD can do for your code, today! We'll use value objects, entities and services to bring order to our mind and code. We'll see how naming things can guide us, but also trick us. We'll rework a piece of code together and improve what it means. And tomorrow you can tell your peers that, technically, you're doing DDD.
Una panoramica su Net::Amazon::EC2 e Net::RackSpace::Servers. Potete trovare la presentazione con le note qui: http://polettix.s3.amazonaws.com/IPW2011/nubilus-perl-1.1-note.pdf
Design Patterns avec PHP 5.3, Symfony et PimpleHugo Hamon
Cette conférence présente deux grands motifs de conception : l'observateur et l'injection de dépendance. Ce sujet allie à la fois théorie et pratique. Le composant autonome EventDispatcher de Symfony ainsi que le conteneur d'injection de dépendance Pimple sont mis à l'honneur avec des exemples pratiques d'usage. Ces cas pratiques combinent du code de l'ORM Propel ainsi que le composant autonome Zend\Search\Lucene du Zend Framework 2
Simple Photo Processing and Web Display with PerlKent Cowgill
I have a small photo gallery on my website and in this presentation, I share
some steps I used in creating a nearly automatic workflow of getting
pictures from my camera to his gallery using Perl.
You might have heard of Domain-Driven Design. You may have heard DDD is a tool to write readable and change-ready code. You may have even heard DDD comes with a lot of talking, and modeling, and customers...
Starting with DDD sounds big, and scary, doesn't it?
But getting started is not scary. Come find out what DDD can do for your code, today! We'll use value objects, entities and services to bring order to our mind and code. We'll see how naming things can guide us, but also trick us. We'll rework a piece of code together and improve what it means. And tomorrow you can tell your peers that, technically, you're doing DDD.
Una panoramica su Net::Amazon::EC2 e Net::RackSpace::Servers. Potete trovare la presentazione con le note qui: http://polettix.s3.amazonaws.com/IPW2011/nubilus-perl-1.1-note.pdf
Design Patterns avec PHP 5.3, Symfony et PimpleHugo Hamon
Cette conférence présente deux grands motifs de conception : l'observateur et l'injection de dépendance. Ce sujet allie à la fois théorie et pratique. Le composant autonome EventDispatcher de Symfony ainsi que le conteneur d'injection de dépendance Pimple sont mis à l'honneur avec des exemples pratiques d'usage. Ces cas pratiques combinent du code de l'ORM Propel ainsi que le composant autonome Zend\Search\Lucene du Zend Framework 2
Taking Perl to Eleven with Higher-Order FunctionsDavid Golden
Sometimes, you just need your Perl to go one higher. This talk will teach you how to use functions that return functions for powerful, succinct solutions to some repetitive coding problems. Along the way, you’ll see concrete examples using higher-order Perl to generate declarative, structured “fake” data for testing.
Persistence is one of the most important part in a PHP project. Persisting data to a database came with PHP/FI and its MySQL support. From native extensions and PHP4 database abstraction libraries to PDO and modern ORM frameworks, you will (re)discover how persistence has evolved during the last decade. This talk will also introduce the future of data persistence with the growing success of alternative storage engines.
This session introduces most well known design patterns to build PHP classes and objects that need to store and fetch data from a relational databases. The session will describe the difference between of the Active Record, the Table and Row Data Gateway and the Data Mapper pattern. We will also examine some technical advantages and drawbacks of these implementations. This talk will expose some of the best PHP tools, which ease database interactions and are built on top of these patterns.
Xlab #1: Advantages of functional programming in Java 8XSolve
Presentation from xlab workshop about functional programming components introduced to the Java 8. How to operate the streams and lambdas in theory and practice.
What makes your code slow? How do you make it faster? And how do you prove it?
This talk will describe my adventures benchmarking and optimizing ordered hashes in Perl, culminating in the release of Hash::Ordered (http://p3rl.org/Hash::Ordered) — which outperforms all other CPAN alternatives, often by a substantial margin. We will cover:
* How to customize Benchmark.pm
* How and why to benchmark at different scales
* Why tied anything in Perl is a horrible idea
* How ordered hashes got faster from a simple algorithm change
Silex is a brand new PHP 5.3 micro framework built on top of the Symfony2 de decoupled components. In this session, we will discover how to build and deploy powerful REST web services with such a micro framework and its embedded tools.
The first part of this talk will introduce the basics of the REST architecture. We fill focus on the main concepts of REST like HTTP methods, URIs and open formats like XML and JSON.
Then, we will discover how to deploy REST services using most of interesting Silex tools like database abstraction layer, template engine and input validation. We will also look at unit and functional testing frameworks with PHPUnit and HTTP caching with Edge Side Includes and Varnish support to improve performances.
The current status of the Corinna OOP proposal for the Perl programming language.
After years of design and discussion, the Perl Steering Committee has accepted the Corinna RFC (in a scaled-back initial form) for inclusion in the Perl language.
This talk gives the history of the proposal and where we're going from here.
Conheça um pouco mais sobre Perl 6, uma linguagem de programação moderna, poderosa e robusta que permitirá que você escreva código de forma ágil e eficiente.
Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)James Titcumb
Have you ever used PHP's built in reflection, only to find you can't do quite what you wanted? What about finding types for parameters or properties? What about reflecting on classes that aren't loaded, so that you can modify them directly?
Better Reflection is an awesome new library that uses magical time-warp techniques* (*actual magic or time-warp not guaranteed) to improve on PHP's built-in reflection by providing additional functionality. In this talk we'll cover what reflection is all about, explore the cool features of Better Reflection already implemented, the difficulties we faced actually writing the thing, and how you can use Better Reflection in your projects to maximise your reflection-fu.
Simple Ways To Be A Better Programmer (OSCON 2007)Michael Schwern
"Simple Ways To Be A Better Programmer' as presented at OSCON 2007 by Michael G Schwern.
The audio is still out of sync, working on it. Downloading will be available once the sync is done.
Taking Perl to Eleven with Higher-Order FunctionsDavid Golden
Sometimes, you just need your Perl to go one higher. This talk will teach you how to use functions that return functions for powerful, succinct solutions to some repetitive coding problems. Along the way, you’ll see concrete examples using higher-order Perl to generate declarative, structured “fake” data for testing.
Persistence is one of the most important part in a PHP project. Persisting data to a database came with PHP/FI and its MySQL support. From native extensions and PHP4 database abstraction libraries to PDO and modern ORM frameworks, you will (re)discover how persistence has evolved during the last decade. This talk will also introduce the future of data persistence with the growing success of alternative storage engines.
This session introduces most well known design patterns to build PHP classes and objects that need to store and fetch data from a relational databases. The session will describe the difference between of the Active Record, the Table and Row Data Gateway and the Data Mapper pattern. We will also examine some technical advantages and drawbacks of these implementations. This talk will expose some of the best PHP tools, which ease database interactions and are built on top of these patterns.
Xlab #1: Advantages of functional programming in Java 8XSolve
Presentation from xlab workshop about functional programming components introduced to the Java 8. How to operate the streams and lambdas in theory and practice.
What makes your code slow? How do you make it faster? And how do you prove it?
This talk will describe my adventures benchmarking and optimizing ordered hashes in Perl, culminating in the release of Hash::Ordered (http://p3rl.org/Hash::Ordered) — which outperforms all other CPAN alternatives, often by a substantial margin. We will cover:
* How to customize Benchmark.pm
* How and why to benchmark at different scales
* Why tied anything in Perl is a horrible idea
* How ordered hashes got faster from a simple algorithm change
Silex is a brand new PHP 5.3 micro framework built on top of the Symfony2 de decoupled components. In this session, we will discover how to build and deploy powerful REST web services with such a micro framework and its embedded tools.
The first part of this talk will introduce the basics of the REST architecture. We fill focus on the main concepts of REST like HTTP methods, URIs and open formats like XML and JSON.
Then, we will discover how to deploy REST services using most of interesting Silex tools like database abstraction layer, template engine and input validation. We will also look at unit and functional testing frameworks with PHPUnit and HTTP caching with Edge Side Includes and Varnish support to improve performances.
The current status of the Corinna OOP proposal for the Perl programming language.
After years of design and discussion, the Perl Steering Committee has accepted the Corinna RFC (in a scaled-back initial form) for inclusion in the Perl language.
This talk gives the history of the proposal and where we're going from here.
Conheça um pouco mais sobre Perl 6, uma linguagem de programação moderna, poderosa e robusta que permitirá que você escreva código de forma ágil e eficiente.
Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)James Titcumb
Have you ever used PHP's built in reflection, only to find you can't do quite what you wanted? What about finding types for parameters or properties? What about reflecting on classes that aren't loaded, so that you can modify them directly?
Better Reflection is an awesome new library that uses magical time-warp techniques* (*actual magic or time-warp not guaranteed) to improve on PHP's built-in reflection by providing additional functionality. In this talk we'll cover what reflection is all about, explore the cool features of Better Reflection already implemented, the difficulties we faced actually writing the thing, and how you can use Better Reflection in your projects to maximise your reflection-fu.
Simple Ways To Be A Better Programmer (OSCON 2007)Michael Schwern
"Simple Ways To Be A Better Programmer' as presented at OSCON 2007 by Michael G Schwern.
The audio is still out of sync, working on it. Downloading will be available once the sync is done.
My slideshow examines the ethics of eating meat, and how it contributes to poor health in humans and animals, as well as the pollution of our environment. It also identifies the benefits of choosing a vegetarian diet.
Dealing with Legacy Perl Code - Peter ScottO'Reilly Media
Peter Scott, author of the O'Reilly School of Technology's Perl Programming Certificate series, talks about how to deal with "legacy" Perl code - written by someone else, or maybe even yourself when you were younger and less wise.
Watch Erik's presentation on PHP Unit Testing to gain familiarity with unit tests and unit testing here at Tagged, with the testing framework currently in place and also learn how to write (better) unit tests. Download his slides here or email him at ejohannessen@tagged.com.
I have 77 modules on the CPAN and I haven't
yet given a talk about most of them. I'll pick ten
useful but less-known modules of mine and give two
minute introductions to each
Helping Data Teams with Puppet / Puppet Camp London - Apr 13, 2015Sergii Khomenko
Puppet is widely known in DevOps community, but not so popular in data teams. Nevertheless, Puppet could easily empower your data teams. In the talk presented hands-on experience of using Puppet for different data topics starting from configuring Windows machine for Business Intelligence and finishing with advanced ranking infrastructures based on Puppet.
The talk will walk you through the process of setting up a standalone Puppet configuration, that used for provisioning Windows machine to be utilized for Business Intelligence purposes like Tableau and Talend Big Data configurations, ETL scheduling etc. Second part of the talk will cover a use-case of Puppet for enabling a lean ranking infrastructure.
With this presentation I hope to show that using SPL doesn't require a PHD and that it really benefits your application design, maintainability and implements best practices to solve common development problems.
Writing Modular Command-line Apps with App::CmdRicardo Signes
It's easy to write command-line programs in Perl. There are a million option parsers to choose from, and Perl makes it easy to deal with input, output, and all that stuff.
Once your program has gotten beyond just taking a few switches, though, it can be difficult to maintain a clear interface and well-tested code. App::Cmd is a lightweight framework for writing easy to manage CLI programs.
This talk provides an introduction to writing programs with App::Cmd.
In the rapidly evolving landscape of technologies, XML continues to play a vital role in structuring, storing, and transporting data across diverse systems. The recent advancements in artificial intelligence (AI) present new methodologies for enhancing XML development workflows, introducing efficiency, automation, and intelligent capabilities. This presentation will outline the scope and perspective of utilizing AI in XML development. The potential benefits and the possible pitfalls will be highlighted, providing a balanced view of the subject.
We will explore the capabilities of AI in understanding XML markup languages and autonomously creating structured XML content. Additionally, we will examine the capacity of AI to enrich plain text with appropriate XML markup. Practical examples and methodological guidelines will be provided to elucidate how AI can be effectively prompted to interpret and generate accurate XML markup.
Further emphasis will be placed on the role of AI in developing XSLT, or schemas such as XSD and Schematron. We will address the techniques and strategies adopted to create prompts for generating code, explaining code, or refactoring the code, and the results achieved.
The discussion will extend to how AI can be used to transform XML content. In particular, the focus will be on the use of AI XPath extension functions in XSLT, Schematron, Schematron Quick Fixes, or for XML content refactoring.
The presentation aims to deliver a comprehensive overview of AI usage in XML development, providing attendees with the necessary knowledge to make informed decisions. Whether you’re at the early stages of adopting AI or considering integrating it in advanced XML development, this presentation will cover all levels of expertise.
By highlighting the potential advantages and challenges of integrating AI with XML development tools and languages, the presentation seeks to inspire thoughtful conversation around the future of XML development. We’ll not only delve into the technical aspects of AI-powered XML development but also discuss practical implications and possible future directions.
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
How to Get CNIC Information System with Paksim Ga.pptxdanishmna97
Pakdata Cf is a groundbreaking system designed to streamline and facilitate access to CNIC information. This innovative platform leverages advanced technology to provide users with efficient and secure access to their CNIC details.
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIVladimir Iglovikov, Ph.D.
Presented by Vladimir Iglovikov:
- https://www.linkedin.com/in/iglovikov/
- https://x.com/viglovikov
- https://www.instagram.com/ternaus/
This presentation delves into the journey of Albumentations.ai, a highly successful open-source library for data augmentation.
Created out of a necessity for superior performance in Kaggle competitions, Albumentations has grown to become a widely used tool among data scientists and machine learning practitioners.
This case study covers various aspects, including:
People: The contributors and community that have supported Albumentations.
Metrics: The success indicators such as downloads, daily active users, GitHub stars, and financial contributions.
Challenges: The hurdles in monetizing open-source projects and measuring user engagement.
Development Practices: Best practices for creating, maintaining, and scaling open-source libraries, including code hygiene, CI/CD, and fast iteration.
Community Building: Strategies for making adoption easy, iterating quickly, and fostering a vibrant, engaged community.
Marketing: Both online and offline marketing tactics, focusing on real, impactful interactions and collaborations.
Mental Health: Maintaining balance and not feeling pressured by user demands.
Key insights include the importance of automation, making the adoption process seamless, and leveraging offline interactions for marketing. The presentation also emphasizes the need for continuous small improvements and building a friendly, inclusive community that contributes to the project's growth.
Vladimir Iglovikov brings his extensive experience as a Kaggle Grandmaster, ex-Staff ML Engineer at Lyft, sharing valuable lessons and practical advice for anyone looking to enhance the adoption of their open-source projects.
Explore more about Albumentations and join the community at:
GitHub: https://github.com/albumentations-team/albumentations
Website: https://albumentations.ai/
LinkedIn: https://www.linkedin.com/company/100504475
Twitter: https://x.com/albumentations
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
Unlocking Productivity: Leveraging the Potential of Copilot in Microsoft 365, a presentation by Christoforos Vlachos, Senior Solutions Manager – Modern Workplace, Uni Systems
Sudheer Mechineni, Head of Application Frameworks, Standard Chartered Bank
Discover how Standard Chartered Bank harnessed the power of Neo4j to transform complex data access challenges into a dynamic, scalable graph database solution. This keynote will cover their journey from initial adoption to deploying a fully automated, enterprise-grade causal cluster, highlighting key strategies for modelling organisational changes and ensuring robust disaster recovery. Learn how these innovations have not only enhanced Standard Chartered Bank’s data infrastructure but also positioned them as pioneers in the banking sector’s adoption of graph technology.
Threats to mobile devices are more prevalent and increasing in scope and complexity. Users of mobile devices desire to take full advantage of the features
available on those devices, but many of the features provide convenience and capability but sacrifice security. This best practices guide outlines steps the users can take to better protect personal devices and information.
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!SOFTTECHHUB
As the digital landscape continually evolves, operating systems play a critical role in shaping user experiences and productivity. The launch of Nitrux Linux 3.5.0 marks a significant milestone, offering a robust alternative to traditional systems such as Windows 11. This article delves into the essence of Nitrux Linux 3.5.0, exploring its unique features, advantages, and how it stands as a compelling choice for both casual users and tech enthusiasts.
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024Neo4j
Neha Bajwa, Vice President of Product Marketing, Neo4j
Join us as we explore breakthrough innovations enabled by interconnected data and AI. Discover firsthand how organizations use relationships in data to uncover contextual insights and solve our most pressing challenges – from optimizing supply chains, detecting fraud, and improving customer experiences to accelerating drug discoveries.
UiPath Test Automation using UiPath Test Suite series, part 6DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 6. In this session, we will cover Test Automation with generative AI and Open AI.
UiPath Test Automation with generative AI and Open AI webinar offers an in-depth exploration of leveraging cutting-edge technologies for test automation within the UiPath platform. Attendees will delve into the integration of generative AI, a test automation solution, with Open AI advanced natural language processing capabilities.
Throughout the session, participants will discover how this synergy empowers testers to automate repetitive tasks, enhance testing accuracy, and expedite the software testing life cycle. Topics covered include the seamless integration process, practical use cases, and the benefits of harnessing AI-driven automation for UiPath testing initiatives. By attending this webinar, testers, and automation professionals can gain valuable insights into harnessing the power of AI to optimize their test automation workflows within the UiPath ecosystem, ultimately driving efficiency and quality in software development processes.
What will you get from this session?
1. Insights into integrating generative AI.
2. Understanding how this integration enhances test automation within the UiPath platform
3. Practical demonstrations
4. Exploration of real-world use cases illustrating the benefits of AI-driven test automation for UiPath
Topics covered:
What is generative AI
Test Automation with generative AI and Open AI.
UiPath integration with generative AI
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Essentials of Automations: The Art of Triggers and Actions in FMESafe Software
In this second installment of our Essentials of Automations webinar series, we’ll explore the landscape of triggers and actions, guiding you through the nuances of authoring and adapting workspaces for seamless automations. Gain an understanding of the full spectrum of triggers and actions available in FME, empowering you to enhance your workspaces for efficient automation.
We’ll kick things off by showcasing the most commonly used event-based triggers, introducing you to various automation workflows like manual triggers, schedules, directory watchers, and more. Plus, see how these elements play out in real scenarios.
Whether you’re tweaking your current setup or building from the ground up, this session will arm you with the tools and insights needed to transform your FME usage into a powerhouse of productivity. Join us to discover effective strategies that simplify complex processes, enhancing your productivity and transforming your data management practices with FME. Let’s turn complexity into clarity and make your workspaces work wonders!
Dr. Sean Tan, Head of Data Science, Changi Airport Group
Discover how Changi Airport Group (CAG) leverages graph technologies and generative AI to revolutionize their search capabilities. This session delves into the unique search needs of CAG’s diverse passengers and customers, showcasing how graph data structures enhance the accuracy and relevance of AI-generated search results, mitigating the risk of “hallucinations” and improving the overall customer journey.
3. Some of you may know me as Perl's bitch.
Let's just say CPAN is MY bitch.
I work as an independent consultant (hire me).
I want to talk to you today about a number.
5. my $self = shift;
Out of 20 million lines of module code in minicpan
~4000 authors on CPAN
60 per author
Half write more than one module
120 per author
Many don't write OO code, so it gets even higher.
Why do we have to do this?
6. sub foo {
my $self = shift;
my($this, $that) = @_;
...
}
Traditional thinking has some answers
1) Nothing can handle all the TMTOWDI of Perl.
2) Backwards compat
3) It's not so bad.
I thought this, too. Then I worked at a place with a simple source filter...
7. sub foo($self, $this, $that) {
...
}
And I coded using that for a year, and it was kinda nice.
Then I left that job.
8. And I found I missed it.
I wanted that back.
I'd become addicted to its conciseness.
It turns out it is that bad, but you only realize that once you've experienced something better.
But...
9. Source filters are the root
of all eval evil.
Because only perl can reliably parse perl.
And a source filter has to run over the whole of your Perl code, not just the one part you care
about.
So source filters are right out.
Which leaves us with...
10. ...nothing.
What was needed was a way to hook into or trick the Perl compiler. To tell us when it saw a
keyword and let us take over. But this is impossible.
When I want something that requires an impossible piece of technology, I talk about it a lot.
And then usually someone makes it possible.
12. use Method;
sub foo :method {
$self->bar();
}
Just after compile time, during the CHECK phase
Method.pm would walk the bytecode of the newly compiled module
Looking for subroutines with the method attribute.
Then it would inject the equivalent of quot;my $self = shiftquot; into the bytecode.
A good idea...
13. ...but it didn't work.
However, it did introduce the technique of injecting code directly into the opcode tree.
It was possible.
14. Then clkao picked up the torch and ran with it.
He got pretty far, and we got Data::Bind out of it
15. but still no way to write subroutine prototypes.
16. Then Matt Trout took a lot of drugs and we got Devel::Declare.
This terrifying hack hooks into Perl's tokenizer and lets you rewrite code just before it's
parsed.
17. Devel::Declare->setup_for(
$caller,
{ $keyword =>
{ const => &parser }
}
);
The end result is you can write new block keywords.
It's not trivial by a long shot, but it works and it's reliable.
I put a little sugar on top of that and released...
19. package Foo;
use Method::Signatures;
method get($key) {
$self->{$key};
}
method set($key, $val) {
$self->{$key} = $val;
}
Isn't that nice?
Method::Signatures rewrites this into normal Perl 5, without a source filter!
So this becomes...
20. package Foo;
sub get {
my $self = shift;
my($key) = @_;
$self->{$key};
}
sub set {
my $self = shift;
my($key, $val) = @_;
$self->{$key} = $val;
}
21. use Method::Signatures;
method get($key) {
$self->{$key};
}
method set($key, $val) {
$self->{$key} = $val;
}
There's only one line of scaffolding here to load the module.
Everything else is significant.
22. sub get {
my $self = shift;
my($key) = @_;
$self->{$key};
}
sub set {
my $self = shift;
my($key, $val) = @_;
$self->{$key} = $val;
}
Compare with this.
Less scaffolding means clearer code. The point is made clear.
23. That's pretty cool.
But if you remember earlier on we said there are 3 excuses why Perl 5 still has no signatures.
28. 3. TMTOWTDI
Well, that's tough.
How do you design a signature system that can do all the things that Perl programmers want
to do?
You get Larry Wall to do it.
29. Perl 6 might not be ready,
But big chunks of the spec are
So I just lifted the best parts from Synopsis 6.
30. method new($class: %args) {
bless {%args}, $class;
}
Let's say you don't want the invocant to be $self. Ok.
That translates into this...
31. sub new {
my $class = shift;
my %args = @_;
bless {%args}, $class;
}
But isn't it wasteful to copy @_? I mean, I could just write this:
32. sub new {
my $class = shift;
bless {@_}, $class;
}
Ok, fine.
33. method new($class: @_) {
bless {@_}, $class;
}
But what if you want to spell out what all the arguments are?
34. sub iso_date {
my $self = shift;
my %date = @_;
return quot;$date{year}-$date{month}-$date{day} quot;.
quot;$date{hour}:$date{min}:$date{sec}quot;;
}
my $date = $obj->iso_date(
year => 2008, month => 2, day => 23,
hour => 12, min => 23, sec => 0
);
Well that's just poo.
35. method iso_date(
:$year, :$month, :$day,
:$hour, :$min, :$sec
)
{
return quot;$year-$month-$day $hour:$min:$secquot;;
}
my $date = $obj->iso_date(
year => 2008, month => 2, day => 23,
hour => 12, min => 23, sec => 0
);
Ahh.
But what if the user forgets an argument? Defaults would be nice.
(Uhh, this currently doesn't parse)
36. method iso_date(:$year, :$month, :$day,
:$hour, :$min, :$sec)
{
return quot;$year-$month-$day $hour:$min:$secquot;;
}
my $date = $obj->iso_date(
year => 2008, month => 2, day => 23,
hour => 12, min => 23, sec => 0
);
This will parse.
That'll be fixed.
38. method iso_date(
:$year, :$month = 1, :$day = 1,
:$hour = 0, :$min = 0, :$sec = 0
)
{
return quot;$year-$month-$day $hour:$min:$secquot;;
}
my $date = $obj->iso_date(); # ???
But if they forget the year it goes all wrong
So how about required arguments?
39. method iso_date(
:$year!, :$month = 1, :$day = 1,
:$hour = 0, :$min = 0, :$sec = 0
)
{
return quot;$year-$month-$day $hour:$min:$secquot;;
}
# Class::iso_date missing required argument $year
my $date = $obj->iso_date(); # error
Now, I want to give you an idea of just how powerful this is.
What if you wanted to do that by hand?
40. method iso_date(
:$year!, :$month = 1, :$day = 1,
:$hour = 0, :$min = 0, :$sec = 0
)
{
return quot;$year-$month-$day $hour:$min:$secquot;;
}
How much code does this represent?
41. use Carp;
sub iso_date {
my $self = shift;
my(%args) = @_;
croak(quot;iso_date() missing required argument $yearquot;)
unless exists $args{'year'};
my $year = delete $args{'year'};
my $month = exists $args{'month'} ? delete $args{'month'} : 1;
my $day = exists $args{'day'} ? delete $args{'day'} : 1;
my $hour = exists $args{'hour'} ? delete $args{'hour'} : 0;
my $min = exists $args{'min'} ? delete $args{'min'} : 0;
my $sec = exists $args{'sec'} ? delete $args{'sec'} : 0;
croak(quot;iso_date() given extra arguments @{[ keys %args ]}quot;)
if keys %args;
return quot;$year-$month-$day $hour:$min:$secquot;;
}
All that.
All that scaffolding goes away.
Now you no longer have to choose between being concise and being thorough.
Some more features...
43. func iso_date(
:$year!, :$month = 1, :$day = 1,
:$hour = 0, :$min = 0, :$sec = 0
)
{
return quot;$year-$month-$day $hour:$min:$secquot;;
}
my $date = iso_date( year => 1975, month => 4, day => 20 );
Doesn't do this yet
But it will
Devel::Declare currently can't override sub
Even if it could, I couldn't because...
44. sub first(&@) {
my($code, @list) = @_;
...
}
...it already means something.
quot;prototypesquot;
If you don't know what they are, feel lucky.
They don't have much to do with signatures.
People sometimes try to pretend they do.
48. method display($text,
:$justify = quot;leftquot;, :$enchef = 0)
{
...
}
# $text = quot;Stuffquot;;
# $justify = quot;rightquot;;
# $enchef = 0;
$obj->display(quot;Stuffquot;, justify => quot;rightquot;);
You can mix positional and named arguments.
There are some restrictions to avoid ambiguity.
(Just make sure to put all the positionals first)
They might be relaxed.
We have required arguments, what about optional ones?
49. method substr(
$str, $offset, $length?, $replacement?
) {
...
}
$obj->substr(quot;stringquot;, 5); # good
$obj->substr(quot;stringquot;); # error
Some C programmers might know the quot;constquot;
Says you're not going to change that variable
Both as a promise to the caller
And a check on your code.
50. method get_page($url is ro) {
# error
$url = 'http://instantrimshot.com';
}
Keeps you honest.
52. When signatures came up on p5p the biggest argument was over aliasing.
Perl 6 passes by reference. Arguments are aliases, not copies.
Perl 5 passes by copy, but it is possible to alias.
53. sub strip_ws {
$_[0] =~ s{^s+}{};
$_[0] =~ s{s+$}{};
return;
}
my $str = quot; foo quot;;
strip_ws($str);
Some folks thought it would be a good idea to alias by default.
There's some powerful things you can do with it.
It saves memory.
But it's very un-Perl5-ish for a function to change its arguments.
Unless the argument is a reference.
It's possible in Perl 5, but the syntax is yucky so few people do it
(or know about it)
It's like a gun you keep locked up and unloaded.
Making Perl 5 silently pass-by-reference is like walking around with a loaded gun.
So I feel its safer to pass by copy in Perl 5, and leave pass-by-reference to Perl 6 where it's
better built into the language.
BUT!
54. method strip_ws($str is alias) {
$str =~ s{^s+}{};
$str =~ s{s+$}{};
return;
}
This is done using the amazing Data::Alias module.
Unfortunately, Data::Alias is busted on Windows < 5.10 or 5.8.9.
Hopefully that will be fixed.
59. 1%
In a fair test between Method::Signatures and equivalent hand-written methods.
That means the equivalent is doing all the same parameter validation.
M::S is 1% slower.
This is because M::S is writing out new Perl code at compile time.
So there's no difference.
If you can hand-write it, M::S can do the same.
Turns out that 1% is the difference between a hard coded subroutine and one assigned to an
alias.
60. This whole adventure started out shortly after 5.10 came out.
Supposing what if we put function signatures into 5.12
Implement the obvious features
Keep it Perl 5 ish
Make sure it can be expanded later
I think we've got it
61. 5.12 or bust!
Half the problem was figuring out what the syntax should be.
Now someone has to implement it inside Perl.
62. What's missing?
I did a code sprint this week to get all the wow features in before PPW.
But there's still a lot to be done.
63. sub?
Devel::Declare can't override subs yet, but they're working on it.
Meanwhile, I could write a func() keyword or something.
Once that works, I'll release a unified quot;signaturesquot; pragma.
64. Debugger is hosed
Devel::Declare causes the debugger to have a fit.
This is the showstopper.
Hopefully there's enough drugs on Earth to help Matt fix it.
66. Types
There's no type or class checks.
It might be added, but I don't want to get into making a Perl 5 type system.
Fortunately, someone else does.
67. MooseX::Method::Signatures
Does basically the same thing, but with antlers.
Provides a more complete Perl 6 signature implementation.
Florian and I have been swapping features.
Hopefully we'll unify the guts.
Combine Method::Signatures with Moose and Perl 5 is starting to look like a real OO
language!
68. package Foo;
use Moose;
use MooseX::Method::Signatures;
method hello (Str :$who, Int :$age where { $_ > 0 })
{
print quot;Hello $who, quot;,
quot;I am $age years old!quot;;
}
Foo->hello( who => quot;youquot;, age => 42 );
79. Simon Cozens
clkao
Matt Trout
Already mentioned for their foundation work
80. Larry and the Perl 6
Dancers
The Perl 6 Design team for doing all the work on function parameters worthy of Perl
81. Matthijs van Duin
(Data::Alias, Sub::Name)
The amazing Data::Alias module which lets quot;is aliasquot; work at full speed
Sub::Name which allows the methods to have the right name in caller()
82. Florian Ragwitz
(MooseX::Method::Signatures)
I've been bouncing ideas of Florian.
He fixed attribute handling
And hacked some on Devel::Declare.
84. One More Thing
there is one more thing.
And I'm not thrilled about the magic aliasing feature.
85. # @foo should not change
$obj->this(@foo);
# @foo might change
$obj->that(@foo);
That's really how it should work in Perl 5.
The magic aliases break that.
Now methods can reach out into their caller's data.
Without warning
That's an encapsulation violation.
But I also think Perl 5's referencing syntax can get clunky.
It's annoying to always be working with references inside methods.
Maybe we can have the best of both worlds...
86. method increment(@args) {
$_++ for @args;
}
my @nums = (2, 4, 8);
# @nums is now (3, 5, 9)
Foo->increment(@nums);