Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Small Perl 6 discoveries IV, hash access

by stevieb (Canon)
on Oct 05, 2017 at 14:01 UTC ( #1200735=note: print w/replies, xml ) Need Help??


in reply to [Perl6] Perl 6 discoveries IV, hash access

Periodically, I dip into perl6, but haven't now in quite some time. However, I do vaguely recall being bit by this, and I believe I got the answer on IRC.

I can't find any clear documentation that states that <> doesn't interpolate, other than a very vague portion of the Class Hash doc:

The general Subscript rules apply providing shortcuts for lists of lit +eral strings, with and without interpolation. my %h = oranges => 'round', bananas => 'bendy'; dd %h<oranges bananas>; # OUTPUT: ("round", "bendy")&#9252; my $fruit = 'bananas'; dd %horanges "$fruit"; # OUTPUT: ("round", "bendy")&#9252;

So it appears as though one needs to use <<>> for interpolation if you're using <> notation.

There's no mention explicitly that <> does not interpolate, unless I'm searching incorrectly.

Replies are listed 'Best First'.
Re^2: Small Perl 6 discoveries IV, hash access
by Laurent_R (Canon) on Oct 07, 2017 at 21:21 UTC
Re^2: Small Perl 6 discoveries IV, hash access
by Anonymous Monk on Oct 05, 2017 at 19:19 UTC
    On a related note, what's a good editor for typing weird unicode characters that perl6 likes, such as double angle brackets ?
      On a related note, what's a good editor

      Well, of course emacs and vi! ;-)

      for typing weird unicode characters that perl6 likes, such as double angle brackets ?

      Probably the same as you use now. The double angle brackets are part of ISO-8859-1 and its supersets ISO-8859-15, and Windows-1252 (at positions 0xAB and 0xBB), ISO-8859-9 (at the same positions), ISO-8859-13 (also at 0xAB and 0xBB), and ISO-8859-16 (again at the same positions). Mac Roman has them at 0xC7 and 0xC8.

      It's not so much an editor problem, but a keyboard layout problem.

      The commonly used keyboard layouts don't even have mappings for all symbols in the ISO-8859-x series. Keyboard layouts were designed for people writing texts in one or a few local languages, on mechanical typewriters. Computer keyboards have largely copied those layouts. See https://en.wikipedia.org/wiki/Keyboard_layout for the big picture, and the keyboard layouts shown in https://de.wikipedia.org/wiki/Tastaturbelegung for a lot of European layouts.

      Look at the classic US layout. It is good for ASCII, but nothing more. The UK layout has some french accented characters due to the french influences in old times. The extended variant adds some more.

      The standard German layout used in Germany and Austria has umlauts (), the sharp s (), and dead keys for writing French and some other accented languages. But it lacks a key kombination for and , also used in French. There are two extended variants (T2 and T3) that are rarely used and practically not available printed or engraved in key caps. T2 is suitable for all latin-based official languages of europe, T3 adds support for minority languages.

      Guess which layout is used in Switzerland. Right, they have their own layout, optimized for typing German, French, Italian and Romansh on a single keyboard. And you won't find the sharp s () on that keyboard, because Swiss german does not use it.

      Hop through a few more layouts (QWERTZ, AZERTY, QWERTY) and you will see a mess of mappings. Layouts for a larger set of language, e.g. US-International are available, and even actually used (e.g. in the Netherlands). BTW: The US-International keyboard allows typing the double angle brackets.

      But 10 Fingers and "only" about 100 keys make it hard to enter all of Unicode. Unicode currently (v10.0) has 139 scripts using 136755 characters, and there is still room for more. So even in future, keyboard layouts will suck if you need to type "exotic" characters. Perhaps even more than today.

      People keep inventing new keyboard layouts, optimized for something, making them hardly useable for something else. There is no best keyboard layout for everything, like there is no best editor for everything.

      Many people prefer coding using the US or the US-International keyboard, simply because most popular programming languages were designed to use the US keyboard.


      There is a solution from the early days of C, using trigraphs instead of characters not available on all platforms and keyboards: http://codingfox.com/4-5-trigraph-characters-in-c-language/

      Trigraph SequenceEqual character
      ??=#
      ??([
      ??)]
      ??/\
      ??<{
      ??>}
      ??!|
      ??^
      ??-~

      This makes hello world look a little bit funny, but it is still readable:

      ??=include <stdio.h> int main() ??< printf("Hello??/nWorld"); return 0; ??>
      #include <stdio.h> int main() { printf("Hello\nWorld"); return 0; }

      I would expect that Perl6 has a similar feature to express "uncommon" Unicode characters by using replacement ASCII sequences. And of course, a little bit of searching ends at Unicode versus ASCII symbols.

      Alexander

      --
      Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

      Has more to do with the OS/keyboard support. Most modern editors support whatever you can get out of your keyboard. If you have a Mac, the keyboard shortcuts are intuitive and trivial to learn; as is switching language support on the keyboard. PCs are a bit of hoop for all that but they are there or available for installation. Don't know about Linux keyboard support personally.

        Don't know about Linux keyboard support

        Linux supports any keyboard mapping you like, only limited by the hardware, as one would expect. The KBD Linux keyboard tools are used to set up the keyboard mapping for the console. See the man pages if you want to know more.

        X11 is a different beast, it has its own, different mapping mechanism. Of course, you can use your own keyboard mapping. For Xorg, there are a few a good articles in the archlinux wiki (Xorg, XKB, extra keys). Desktop environments like Gnome, KDE, xfce can also influence the keyboard mapping, using the mechanisms embedded in the X11 system.

        Alexander

        --
        Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
        If you have a Mac, the keyboard shortcuts are intuitive and trivial to learn
        Oh, cool, so is option-shift-backslash. Obvious!
      On a related note, what's a good editor for typing weird unicode characters that perl6 likes, such as double angle brackets ?
      Unless I missed it, nobody so far has provided link to the following documentation, which, I think, brings at least some partial answers to your question: https://docs.perl6.org/language/unicode_entry.
        That's very helpful. I have to point out that there is no default binding for normal-width 「corner quotes」 (U+FF62 and U+FF63) in vim, although 「double-width」 ones (U+300C and U+300D) are available. Also, the vim documentation page (vimdoc.sourceforge.net/htmldoc/digraph.html) is served with no encoding specified, so you might have to manually set the encoding to read it properly. That's pretty hilarious.
      You can use whatever snippet plugin is available for your editor.


      holli

      You can lead your users to water, but alas, you cannot drown them.
        I'm not sure what a "snippet plugin" is, but I assume you're telling me to set up my own ad-hoc unicode entry system. Um... thanks. I'm sure that won't become unmanageable.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1200735]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2021-05-08 05:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (96 votes). Check out past polls.

    Notices?