News for hackers. Stuff that matters.
Re:Red programming language 0.6.2: LibRed and Macros by abecedarius on Monday March 27, 2017 @05:40PM (#13972036)
What does a type being built-in do for you extra? In ES6 you can define a template string builder which you could name, for instance, ipv4, and then when you want an IPv4 address literal you say

    ipv4`192.168.0.1`
and get your object. Are there other benefits besides a literal syntax? (Not to slag on Red. One advantage I can see is avoiding the call at runtime to the ipv4 function.)
Re:Red programming language 0.6.2: LibRed and Macros by greggirwin on Monday March 27, 2017 @06:34PM (#13972441)
I'll add to my reply, because this is a really good question.

Red doesn't have all types in place yet (e.g. date! is coming, and maybe an @ref type, among others), but can still load the following:

  at 10:00 send [email protected] a link to http://red-lang.org (216.239.32.21)
  delete %/c/temp/junk.dat
  assign #DECAFBAD-7337 to John
  make the main window 800x600 with a color of 255.0.0
  answer: yes
Here's a quick console session showing what types it found:

  >> blk: [  at 10:00 send [email protected] a link to http://red-lang.org (216.239.32.21)
  [      delete %/c/temp/junk.dat
  [      assign #DECAFBAD-7337 to John
  [      make the main window 800x600 with a color of 255.0.0
  [      answer: yes
  [    ]
  == [at 10:00:00 send [email protected] a link to http://red-lang.org (216.239.32.21) 
      delete %/c/temp/junk.dat 

  >> unique collect [foreach val blk [keep type? val]]
  == [word! time! email! url! paren! file! issue! pair! tuple! set-word!]
And you can parse at that level:

  >> parse blk [
  [        some [
  [            'window set val pair! (print ["size:" val])
  [            | 'assign set val issue! (print ["issue:" val])
  [            | 'link 'to set val url! (print ["link:" val])
  [            | skip
  [        ]
  [    ]

  link: http://red-lang.org
  issue: DECAFBAD-7337
  size: 800x600
Of course, you could do something similar in ES6. If you use template literals, your data might look like this:

  at time`10:00` send email`[email protected]` a link to url`http://red-lang.org` paren`(ipv4`216.239.32.21`)`
  delete file`%/c/temp/junk.dat`
  assign issue`#DECAFBAD-7337` to John
  make the main window pair`800x600` with a color of color`255.0.0`
  name`answer:` bool`yes`
Sorry for getting carried away. :)
Re:Red programming language 0.6.2: LibRed and Macros by abecedarius on Monday March 27, 2017 @07:02PM (#13972602)
That does look handy! I guess there must be a tradeoff in having your text default to meaning plain words if you mess up the syntax? Versus hopefully getting an error in the ES6 case.
Re:Red programming language 0.6.2: LibRed and Macros by greggirwin on Monday March 27, 2017 @07:17PM (#13972675)
You can always get errors of course. The new `load/trap` feature gives you more flexibility in that area, but there are limits as with anything. Pretty handy for CLIs, though, when you expect your audience to know what "syntax" even means. :)
Re:Red programming language 0.6.2: LibRed and Macros by vram22 on Tuesday March 28, 2017 @10:08AM (#13976668)
No need to apologize, that was a good example :)

I liked this big:

>> unique collect [foreach val blk [keep type? val]] == [word! time! email! url! paren! file! issue! pair! tuple! set-word!]

I think it could almost be read and understood by a person who does not know REBOL or Red.

Re:Red programming language 0.6.2: LibRed and Macros by greggirwin on Tuesday March 28, 2017 @04:58PM (#13980638)
Yup. We often write code like normal programmers, but sometimes we do build up vocabularies more, even when not using `parse` to write DSLs.

"Red or REBOL" = Redbol (sounds like Red Bull) :) And where Perl has Mongers, Ruby has Rubyists, Python has Pythonistas, and Rebol has Rebolers, Red has Reducers.

Re:Red programming language 0.6.2: LibRed and Macros by vram22 on Thursday March 30, 2017 @12:36PM (#13996847)
Ha, Reducers is a good term, considering: the goals of Red (reducing complexity being one), the small size of Red (and REBOL) programs that get non-trivial things done, and finally the size of the software itself (the interpreter - and also compiler in the case of Red). Even the small EXE sizes, in fact (though I've only created EXEs for small programs so far, with it).
Re:Red programming language 0.6.2: LibRed and Macros by dmitriid on Tuesday March 28, 2017 @08:19AM (#13975921)
What are the chances of authors getting the types like email and uri incorrect?

Oh, very high I would say

Re:Red programming language 0.6.2: LibRed and Macros by greggirwin on Monday March 27, 2017 @06:09PM (#13972268)
One of the key reasons for having a lot of literal forms is because REBOL was designed as a messaging language. You can think of it as a data format as much as anything. Template literals in ES6 help with DSL support, which is fundamental in Red's design. It doesn't mean you can just include anything in Red, but the wide array of native forms lets you build a lot of embedded DSLs without resorting to string parsing. Being able to parse at the block level (i.e. datatype level) is really nice.

A couple other new features make dealing with non-loadable input easier too. You can use macros to pre-process data, trap errors that `load` triggers and still get back a block of values, or spec some simple rules in `system/lexer/pre-load`. That's another way we might deal with IPv6 values.

Re:Red programming language 0.6.2: LibRed and Macros by pekr on Tuesday March 28, 2017 @01:07AM (#13974242)
Yes, a message format. What I would add is, that today ppl are using JSON, not realising, that it is de-facto a Rebol, or at least strongly inspired by Rebol. Well - who wants to use cryptic formats anyway, right? :-)