Unicode::Overload 0.01
Sponsored Links
Unicode::Overload 0.01 Ranking & Summary
File size:
0.005 MB
Platform:
Any Platform
License:
Perl Artistic License
Price:
Downloads:
835
Date added:
2007-07-12
Publisher:
Jeffrey Goff
Unicode::Overload 0.01 description
Unicode::Overload is a Perl source filter to implement Unicode operations.
SYNOPSIS
use charnames :full;
use Unicode::Overload (
"N{UNION}" => infix =>
sub { my %a = map{$_=>1}@{$_[0]};
my %b = map{$_=>1}@{$_[1]};
return keys(%a,$b); },
"N{SUPERSCRIPT TWO}" => postfix => sub { $_[0] ** 2 },
"N{NOT SIGN}" => prefix => sub { !$_[0] },
[ "N{LEFT FLOOR}", "N{RIGHT FLOOR}" ] => outfix =>
sub { POSIX::floor($_[0]) },
);
@union = (@a N{UNION @b); # Parentheses REQUIRED
die "Pythagoras was WRONG!" # Same here
unless sqrt((3)N{SUPERSCRIPT TWO} + (4)N{SUPERSCRIPT TWO}) == 5;
$b = N{NOT SIGN}($b); # Required here too
die "Fell through floor" # Balanced characters form their own parentheses
unless N{LEFT FLOOR}-3.2N{RIGHT FLOOR} == 4;
Allows you to declare your own Unicode operators and have them behave as prefix (like sigma or integral), postfix (like superscripted 2), infix (like union), or outfix (like the floor operator, with the L-like and J-like brackets).
To keep this document friendly to people without UTF-8 terminals, the N{} syntax for Unicode characters will be used throughout, but please note that the N{} characters can be replaced with the actual UTF-8 characters anywhere.
Also, please note that since Perl 5 doesnt support the notion of arbitrary operators, this module cheats and uses source filters to do its job. As such, all "operators" must have their arguments enclosed in parentheses. This limitation will be lifted when a better way to do this is found.
Also, note that since these arent "real" operators there is no way (at the moment) to specify precedence. All Unicode "operators" have the precedence (such as it is) of function calls, as they all get transformed into function calls inline before interpreting.
In addition, due to a weird unicode-related bug, only one character per operator is currently permitted. Despite behaving correctly elsewhere, substr() thinks that one character equals one byte inside Unicode::Overload .
Anyway, this module defines four basic types of operators. Prefix and infix should be familiar to most users of perl, as prefix operators are basically function calls without the parens. Infix operators are of course the familiar + etcetera.
The best analogy for postfix operators is probably the algebraic notation for squares. $a**2 is perls notation, ($a)N{SUPERSCRIPT TWO} is the Unicode::Overload equivalent, looking much closer to a mathematical expression, with the 2 in its proper position.
Outfix is the last operator, and a little odd. Outfix can best be thought of as user-definable brackets. One of the more common uses for this notation again comes from mathematics in the guise of the floor operator. Looking like brackets with the top bar missing, they return effectively POSIX::floor() of their contents.
Since outfix operators define their own brackets, extra parentheses are not needed on this type of operator.
A quick summary follows:
prefix
Operator goes directly before the parentheses containing its operands. Whitespace is allowed between the operator and opening parenthesis. This acts like a function call.
Sample: N{NOT SIGN}($b)
postfix
Operator goes directly after the parentheses containing its operands. Whitespace is allowed between the closing parenthesis and operator. This doesnt have a good Perl equivalent, but there are many equivalents in algebra, probably the most common being:
Sample: ($a+$b)N{SUPERSCRIPT TWO}
infix
Operator goes somewhere inside the parentheses. Whitespace is allowed between either parenthesis and the operator.
Sample: ($a N{ELEMENT OF} @list)
outfix
Operators surround their arguments and are translated into parentheses. As such, whitespace is allowed anywhere inside the operator pairs. There is no requirement that the operators be visually symmetrical, although it helps.
Sampe: $c=N{LEFT FLOOR}$a_+$bN{RIGHT FLOOR}
The requirements for parentheses will be removed as soon as I can figure out how to make these operators behave closer to perl builtins. Nesting is perfectly legal, but multiple infix operators cant coexists within one set of parentheses.
SYNOPSIS
use charnames :full;
use Unicode::Overload (
"N{UNION}" => infix =>
sub { my %a = map{$_=>1}@{$_[0]};
my %b = map{$_=>1}@{$_[1]};
return keys(%a,$b); },
"N{SUPERSCRIPT TWO}" => postfix => sub { $_[0] ** 2 },
"N{NOT SIGN}" => prefix => sub { !$_[0] },
[ "N{LEFT FLOOR}", "N{RIGHT FLOOR}" ] => outfix =>
sub { POSIX::floor($_[0]) },
);
@union = (@a N{UNION @b); # Parentheses REQUIRED
die "Pythagoras was WRONG!" # Same here
unless sqrt((3)N{SUPERSCRIPT TWO} + (4)N{SUPERSCRIPT TWO}) == 5;
$b = N{NOT SIGN}($b); # Required here too
die "Fell through floor" # Balanced characters form their own parentheses
unless N{LEFT FLOOR}-3.2N{RIGHT FLOOR} == 4;
Allows you to declare your own Unicode operators and have them behave as prefix (like sigma or integral), postfix (like superscripted 2), infix (like union), or outfix (like the floor operator, with the L-like and J-like brackets).
To keep this document friendly to people without UTF-8 terminals, the N{} syntax for Unicode characters will be used throughout, but please note that the N{} characters can be replaced with the actual UTF-8 characters anywhere.
Also, please note that since Perl 5 doesnt support the notion of arbitrary operators, this module cheats and uses source filters to do its job. As such, all "operators" must have their arguments enclosed in parentheses. This limitation will be lifted when a better way to do this is found.
Also, note that since these arent "real" operators there is no way (at the moment) to specify precedence. All Unicode "operators" have the precedence (such as it is) of function calls, as they all get transformed into function calls inline before interpreting.
In addition, due to a weird unicode-related bug, only one character per operator is currently permitted. Despite behaving correctly elsewhere, substr() thinks that one character equals one byte inside Unicode::Overload .
Anyway, this module defines four basic types of operators. Prefix and infix should be familiar to most users of perl, as prefix operators are basically function calls without the parens. Infix operators are of course the familiar + etcetera.
The best analogy for postfix operators is probably the algebraic notation for squares. $a**2 is perls notation, ($a)N{SUPERSCRIPT TWO} is the Unicode::Overload equivalent, looking much closer to a mathematical expression, with the 2 in its proper position.
Outfix is the last operator, and a little odd. Outfix can best be thought of as user-definable brackets. One of the more common uses for this notation again comes from mathematics in the guise of the floor operator. Looking like brackets with the top bar missing, they return effectively POSIX::floor() of their contents.
Since outfix operators define their own brackets, extra parentheses are not needed on this type of operator.
A quick summary follows:
prefix
Operator goes directly before the parentheses containing its operands. Whitespace is allowed between the operator and opening parenthesis. This acts like a function call.
Sample: N{NOT SIGN}($b)
postfix
Operator goes directly after the parentheses containing its operands. Whitespace is allowed between the closing parenthesis and operator. This doesnt have a good Perl equivalent, but there are many equivalents in algebra, probably the most common being:
Sample: ($a+$b)N{SUPERSCRIPT TWO}
infix
Operator goes somewhere inside the parentheses. Whitespace is allowed between either parenthesis and the operator.
Sample: ($a N{ELEMENT OF} @list)
outfix
Operators surround their arguments and are translated into parentheses. As such, whitespace is allowed anywhere inside the operator pairs. There is no requirement that the operators be visually symmetrical, although it helps.
Sampe: $c=N{LEFT FLOOR}$a_+$bN{RIGHT FLOOR}
The requirements for parentheses will be removed as soon as I can figure out how to make these operators behave closer to perl builtins. Nesting is perfectly legal, but multiple infix operators cant coexists within one set of parentheses.
Unicode::Overload 0.01 Screenshot
Unicode::Overload 0.01 Keywords
SUPERSCRIPT
SUPERSCRIPT TWO
Overload 0.01
RIGHT FLOOR
RIGHT
NOT SIGN
to implement
source filter
n
operators
operator
parentheses
floor
Perl
Unicode::Overload
UnicodeOverload
Bookmark Unicode::Overload 0.01
Unicode::Overload 0.01 Copyright
WareSeeker periodically updates pricing and software information of Unicode::Overload 0.01 full version from the publisher, so some information may be slightly out-of-date. You should confirm all information before relying on it. Software piracy is theft, Using crack, password, serial numbers, registration codes, key generators is illegal and prevent future development of Unicode::Overload 0.01 Edition. Download links are directly from our publisher sites, torrent files or links from rapidshare.com, yousendit.com or megaupload.com are not allowed
Featured Software
Want to place your software product here?
Please contact us for consideration.
Contact WareSeeker.com
Related Information
tour operators
operators union
schools for crane operators
what are boolean operators
boolean operators
owner operators
unix ksh operators expression
floor jacks
operator band
operators local 302
use of parentheses
hardwood floors
floor buffer
operators union 302
operator music
superscript two unicode
parentheses lyrics
operator c++
Related Software
Unicode::Escape is a Perl module with escape and unescape Unicode characters other than ASCII. Free Download
Bundle::Unicode is a Perl bundle to install Unicode modules and their dependencies. Free Download
Unicode::Regex::Set is a subtraction and intersection of Character Sets in Unicode Regular Expressions. Free Download
mount_and open is a service menu is a port of media_realfolder and the perlscript kio_media_realfolder. Free Download
Convert::CharMap is a Perl module that can conversion between Unicode Character Maps. Free Download
Devel::Backtrace is a Perl module for object-oriented backtrace. Free Download
OpenGeDB Perl module is a module to access the OpenGeoDB database and calculate all ZIP codes in a certain radius. Free Download
Bundle::DBWIZ is a Perl CPAN Bundle for DBWIZ. Free Download
Latest Software
Popular Software
Favourite Software