Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.96k stars 556 forks source link

RFE: allow user created operators #16578

Open p5pRT opened 6 years ago

p5pRT commented 6 years ago

Migrated from rt.perl.org#133243 (status was 'new')

Searchable as RT133243$

p5pRT commented 6 years ago

From perl-diddler@tlinx.org

Created by perl-diddler@tlinx.org

I was working on a program and ran into a case where I wanted to use a NAND operator ( ⊼ ). As a work-around\, I can use !(A^B) -- not xor\, but it would be really cool if perl had a way to define -- ESPECIALLY operators that were easily expressible in terms of existing operators.

I don't really want to override or lost existing operators -- so being able to add new ones would be rather cool. As an aside\, unicode uses ' ⊻ ' for XOR\, and ' ⊽ ' for NOR\, but I could see something like defining name=>'NOR' symbol=>⊼ imple=!^ or as a sub NAND($$){!$_[0] ^ $_[1] }. Certainly could ressurect that APL look & feel ;-). (OK\, maybe not\, but...) I would be nice if perl could put some of those cool Unicode character to more use.

Perl Info ``` Flags: category=core severity=wishlist Site configuration information for perl 5.16.3: Configured by law at Wed Jan 22 12:58:58 PST 2014. Summary of my perl5 (revision 5 version 16 subversion 3) configuration: Platform: osname=linux, osvers=3.12.0-isht-van, archname=x86_64-linux-thread-multi-ld uname='linux ishtar 3.12.0-isht-van #1 smp preempt wed nov 13 16:50:51 pst 2013 x86_64 x86_64 x86_64 gnulinux ' config_args='' hint=previous, useposix=true, d_sigaction=define useithreads=define, usemultiplicity=define useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef use64bitint=define, use64bitall=define, uselongdouble=define usemymalloc=n, bincompat5005=undef Compiler: cc='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-g -O2', cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64' ccversion='', gccversion='4.8.1 20130909 [gcc-4_8-branch revision 202388]', gccosandvers='' intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16 ivtype='long', ivsize=8, nvtype='long double', nvsize=16, Off_t='off_t', lseeksize=8 alignbytes=16, prototype=define Linker and Libraries: ld='gcc', ldflags ='-g -fstack-protector -fPIC' libpth=/usr/lib64 /lib64 libs=-lnsl -lndbm -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc -lgdbm_compat perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc libc=/lib/libc-2.18.so, so=so, useshrplib=true, libperl=libperl-5.16.3.so gnulibc_version='2.18' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-rpath,/home/perl/perl-5.16.3/lib/x86_64-linux-thread-multi-ld/CORE' cccdlflags='-fPIC', lddlflags='-shared -g -O2 -fstack-protector -fPIC' Locally applied patches: @INC for perl 5.16.3: /home/law/bin/lib /home/perl/perl-5.16.3/lib/site/x86_64-linux-thread-multi-ld /home/perl/perl-5.16.3/lib/site /home/perl/perl-5.16.3/lib/x86_64-linux-thread-multi-ld /home/perl/perl-5.16.3/lib . Environment for perl 5.16.3: HOME=/home/law LANG (unset) LANGUAGE (unset) LC_COLLATE=C LC_CTYPE=en_US.UTF-8 LC_MESSAGES=C LC_MONETARY=C LC_NUMERIC=C LC_TIME=C LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=.:/sbin:/home/law/bin/lib:/home/law/bin:/usr/local/bin:/usr/bin:/bin:/opt/kde3/bin:/usr/sbin:/etc/local/func_lib:/home/law/lib PERL5OPT=-Mutf8 -CSA -I/home/law/bin/lib PERL_BADLANG (unset) SHELL=/bin/bash ```