News for hackers. Stuff that matters.
Re:Show HN: Bato – A Filipino Programming Language by memco on Friday January 12, 2018 @09:58AM (#16133290)
Can't recall exactly where I saw it, but one of the major language designers (I think for Perl) was talking about how there was a plan to abstract some things like quotes such that a character used to quote a string in any spoken language would be a valid way to declare a string. This didn't seem to go so far as to also allow this for keywords, but for symbols the thought was that you could simplify things a little bit for others by not requiring only symbols common to an english keyboard.
Re:Show HN: Bato – A Filipino Programming Language by liveoneggs on Friday January 12, 2018 @10:11AM (#16133415)
in perl 6 you can quote strings in quite a few ways!

https://docs.perl6.org/language/quoting

"Quoting" is all defined inside of a sub-language called "Q"

Re:Show HN: Bato – A Filipino Programming Language by vidarh on Friday January 12, 2018 @12:02PM (#16134316)
Ruby has pretty much the same flexibility. "%" followed by almost any non-alphabetic character starts a quoted string. But most then become the quote character. If the quote character is at least <,(,[ or { then the end-quote character is the corresponding >,),] or }. These are all equivalent:

%<x>

%"x"

%{x}

%!x!

Unfortunately the rules are loose enough that even space is a valid quote character. So this too is equivalent to the above:

% x

("% x ")

Re:Show HN: Bato – A Filipino Programming Language by b2gills on Wednesday January 17, 2018 @05:24PM (#16172598)
No it doesn't have the same flexibility.

Perl 6's string quoting sub language has various feature flags that you can turn on or off.

Here are a few of the basic ones shown in valid code (comments and newlines included)

  # start quoting with no features enabled
  # (not even backslashing the delimiter is enabled)
  Q

    :scalar    # enable $foo
    :array     # enable @foo[]
    :hash      # enable %foo{}
    :closure   # enable { 12/3 }
    :function  # enable &foo('bar')
    :single    # turns on backslashing the delimiter
    :backslash # enable \n
  
    :!exec     # turn off executing it (redundant)
    :exec(0)   # another syntax for turning off a feature
  
  {…}          # various delimiters are allowed (generally punctuation)
There are shorter variants of each of the feature flags. :c => :closure

I would like to point out that the parsing of the :closure and :function part of the sub language is reentrant. (Actually most of them add some form of reentrancy, it is just harder to show it for the others)

  "a b &foo( "c d &bar( "baz" )" )"
Note that this reuses the base Perl 6 parser, and that is why it is reentrant.

There are shortcuts for regularly used forms

  「」 =:= Q[]
  
  '' =:=  q[] =:= Q:q[]  =:= Q:single[]
  
  "" =:= qq[] =:= Q:qq[] =:= Q:double[]
     =:= Q:b:s:a:h:c:f[]
     =:= Q:backslash:scalar:array:hash:closure:function[]
The ability to turn off features can be useful

  qq :!c [a {\n  b\n} c] # { and } don't form a closure here
I would like to point out that the :foo syntax is used everywhere in the language for named parameters to routines and operators (most operators are implemented as subroutines)

  :foo =:= :foo( True ) =:= foo => True
  
  :!bar =:= :bar( False ) =:= bar => False
  
  :$baz =:= :baz( $baz ) =:= baz => $baz
If the delimiters are paired () <> {} 「」 «» “” ‘’ you can double up on them.

  q<FOO> =:= q<<FOO>> =:= q<<<<<FOO>>>>>
This is useful to avoid having to backslash a delimiter within the string, or trying to find a delimiter that isn't in the string.

  q<< <a> >> =:= q' <a> '
Re:Show HN: Bato – A Filipino Programming Language by sethrin on Friday January 12, 2018 @03:39PM (#16136114)
One more equivalent expression: ?x

A question mark followed by any other single character is treated as a string literal containing that character.