Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 10:28
    dockimbel commented #4962
  • 10:27
    dockimbel commented #4962
  • 10:25
    dockimbel closed #4781
  • 10:25
    dockimbel milestoned #4781
  • 10:25
    dockimbel labeled #4781
  • 10:25
    dockimbel labeled #4781
  • 10:25
    dockimbel labeled #4781
  • 10:24

    dockimbel on master

    TESTS: regression test for #478… (compare)

  • 10:20

    dockimbel on master

    FIX: issue #4781 (Decimals in t… (compare)

  • 10:08
    dockimbel edited #4781
  • 06:46
    Oldes commented #4960
  • 06:45
    Oldes commented #4960
  • 06:38
    Oldes commented #4960
  • 01:57
    qtxie commented on e026f83
  • 01:56

    qtxie on audio

    FEAT: wave generator GUI test Merge pull request #4966 from h… (compare)

  • 01:56
    qtxie closed #4966
  • Sep 16 21:47
    hiiamboris commented #4962
  • Sep 16 21:42
    hiiamboris reopened #4962
  • Sep 16 21:42
    hiiamboris commented #4962
  • Sep 16 21:10
    hiiamboris commented on e026f83
Raghu Ranganathan
@razetime
I'll note those down
I did try not not before you showed none <> :P
after all, unreadability is one of the more fun parts in golf
hiiamboris
@hiiamboris
haha
karthik
@kskarthik:poddery.com
[m]
@razetime: you're working on any program in Red or exploring?
1 reply
karthik
@kskarthik:poddery.com
[m]
BTW Any there any real world programs in Red?
Galen Ivanov
@GalenIvanov
@razetime to logic! find ... can be shortened to to on find... (or any one of true false on off yes no instead no)
11 replies
gltewalt (The other Greg)
@gltewalt:matrix.org
[m]

Small advantage to that weird naming style where the first letter is a type hint.
sHeadings
fVerify-headings

Or something like that

Hard to find one word verbs for functions.
Which probably means in a perfect world that my functions are doing too much
Gregg Irwin
@greggirwin
I used Hungarian Notation a lot in the 90s. If you only have 6 types, starting with unique letters, it works much better than it would in Red. Also why you end up with things like sz as prefixes for "C string", because that makes sense. Well, it does if you're a C programmer. But it's also onerous to maintain, and often hints at leaking details through large systems. If you have a rich, strong type system, it's less helpful.
hardkorebob
@hardkorebob
Wow. Amazing work. Truly what the future has to be more like. I'm truly blown away at this. Im glad I started to research new languages. Looking forward in having some hands-on. Will build latest from source on a Devuan 3 amd64.
hiiamboris
@hiiamboris
We all share the feeling. Welcome @hardkorebob
hardkorebob
@hardkorebob
I'm here to help too. I am fluent in Spanish as well.
Thank you hiiamboris
hiiamboris
@hiiamboris
In the topic of https://gitter.im/red/red/welcome room you'll find learning resources we're usually advising. There's a huge lot of work ahead in Red, so I'm sure everyone willing to help will find a way that he likes best ;)
hardkorebob
@hardkorebob
I was about to ask. :)
Gregg Irwin
@greggirwin
Welcome @hardkorebob !
hiiamboris
@hiiamboris

We were discussing string interpolation with Gregg, and would like others input.

Preliminary design was #composite macro and composite function. Both are described here, but TL;DR is #composite turns a string into a rejoin with block and composite does it internally and returns rejoined string:

>> probe expand-directives [#composite {"(player)" "(vfile)" --audio-file "(afile)"}]
[rejoin [{"} (player) {" "} (vfile) {" --audio-file "} (afile) {"}]]

The latter as you can see gets very ugly at times. So first purpose of it is readability. Second purpose is localization (see on the same page).

There are however some issues.

  • #composite is a long thing to type. I found myself writing macro wrappers around it: #print for print #composite, ERROR for do make error! #composite and so on.
  • #composite can't accept strings indirectly (being a macro), e.g. strings conditionally fetched or built at runtime.
  • composite (func) requires runtime binding, and that we provide it every time (see the above page for details). Which is a bag of gotchas for everyone not deeply familiar with Red.
  • What escape syntax should be preferred? Current implementation uses (\ to denote literal (, which is backwards ☻

My stats so far are:

  • ERROR is a very common use case, probably 50-70% of my use of composite.
  • #print is most of the rest.
  • other #composite uses are present (e.g. composing file content) but not very numerous.
  • composite (function) I only used once.

Some recent ideas:

  • Replace #composite "value=(v)" with a shorter macro, e.g. `"value=(v)"` . Backtick does not stick to strings and tags, but stick to files and raw-strings (though it can be fixed). No need for wrappers anymore. Such triple quotes are harder to count visually though.
  • Most languages reserve some quotation format for this (very common) use. We could code backticks directly in the lexer to transform strings like `value=(v)` into rejoin ["value=" (v)] (or just into blocks?) on load. That however harms localization, as we don't get the string form anymore and need some kludges to extract it.
  • We can build and expand macros at runtime as shown above, so there really is no strict need for composite function and we may even abandon it, or make it a wrapper around the macro: build the macro pattern, expand, bind and evaluate.

What do you guys think? Any ideas on how to best support interpolation? Have you used it (or wanted to use) in your code?

gtzip
@gtzip
Value for templating?
I've used rejoin and compose rejoin as a common pattern for some templates.
At first i wished for it, but rejoin with a block is essentially bizzaro string interpolation. The inverse sort of.
Its a must for string heavy languages, but for red?
Gregg Irwin
@greggirwin
Another question is the markers for placeholders. In mine I used :( ... ): (what @hiiamboris refers to as the sad eomji format. :^) @giesse pointed out in another chat the main binding problem, which Boris also covers. Basically, the simple case where you use it in a func, but then it needs a context given because it's not a block to begin with.
Greg T
@gltewalt
log-info compstr "Started worker <%name%> PID: (<%pid%>)"
Is there something against the rebol choice of <%..%> ?
I know that folks are used to parens for compose
Sad emoji isn't bad until you throw in set-words or get words
Greg T
@gltewalt
And forgive me if I've forgotten if backticks make for an illegal word
Those would be fairly clean
I suppose going by the boris breakdown, I'd prefer \var\ ^\text\, then (var) (\text)
Greg T
@gltewalt
And would vote for macro
hiiamboris
@hiiamboris

Is there something against the rebol choice of <%..%> ?

So unreadable IMO as if it was not designed at all ;)

hardkorebob
@hardkorebob
Im not a developer per se. I do work with the command line a lot in Linux and I would consider myself a PowerUser than anything else. Readability is definitely very nice but maybe the whole thing needs to relooked at. I dunno. Just my 2 cents.
I am very new to Red and the whole Rebol/Forth family. But I love to learn and I am willing to share my insights.
Boleslav Březovský
@rebolek
Comon format for the delimiters is also {{ and }} (see Mustache)
And of course I would welcome an option to override default delimiters.
5 replies
Galen Ivanov
@GalenIvanov
While working on the Red functions for Python programmers article, I wrote a simple format function that uses a tiny formatting DSL. I find it slightly related to the composite function and that's why I'm posting it here.
Boleslav Březovský
@rebolek
@GalenIvanov nice!
Galen Ivanov
@GalenIvanov
Thanks!
hiiamboris
@hiiamboris
Comparison of short macro formats as currently possible to lex:
string alt string tag file note
`"value=(v)"` `{value=(v)}` `<value=(v)>` ` %"value=(v)" `
@"value=(v)" @{value=(v)} @<value=(v)> @%"value=(v)" 1
&"value=(v)" &{value=(v)} &<value=(v)> & %"value=(v)" 2
/"value=(v)"/ /{value=(v)}/ / <value=(v)> / /%"value=(v)"/
="value=(v)"= ={value=(v)}= =<value=(v)>= = %"value=(v)" =
^"value=(v)"^ ^{value=(v)}^ ^<value=(v)>^ ^ %"value=(v)" ^
  1. similar to reshape
  2. & can't be an operator then
gltewalt (The other Greg)
@gltewalt:matrix.org
[m]
Well I can say you've done the work and provided examples and justifications, which is normally an Irwin requirement. Aesthetically, parens are not my favorite but I'm sure I would get used to it.
Greg T
@gltewalt
First short macro format would be my pick
Gregg Irwin
@greggirwin
@hiiamboris knows how to sway me. I'm on to him though.
Gregg Irwin
@greggirwin

@gtzip the question of value in Red is a good one. We tend to think in terms of little strings, and bits of code we compose or rejoin. While we don't have measurements, we do have evidence that non-developers understand, and can effectively use, templates (e.g. mail merge). Where blocks of code are normal for us, they are foreign to others, flipping the model on its head. No longer are there placeholders within a string of text, but there are interspersed bits of text and expressions. In my own work, I've used external templates more than internal, not counting rejoin/reform cases where devs are the only consumer.

I also noted to @hiiamboris that a key elements is the WYSIWYG aspect. Rejoin/reform make you look at every text snippet to make sure you have leading trailing spaces right. That's probably one of my most common mistakes in formatting. The other place that's huge is in multiline string formatting. e.g. templated email bodies. Compare this R2 build-markup example

        body {
            The <%PROCESS_NAME%> process sent DISKPART the following commands:

                <%mold MARKUP_1%>

            The DISKPART result was:

                <%mold MARKUP_2%>
        }

with something like

        body [
            "The " <%PROCESS_NAME%> " process sent DISKPART the following commands:^/^/"

            tab   <%mold MARKUP_1%>

            "^/^/The DISKPART result was:^/^/"

            tab    <%mold MARKUP_2%>
        ]

We can put the former in a user's hands, and if errors aren't dangerous, e.g. malformed fields, they can still deal with it. The latter, based on my experience, is not user friendly. It can be especially confusing because the blank lines in the template do not affect the output.

hiiamboris
@hiiamboris
I can add that first time I saw Gregg's #composite my reaction was "why would we ever want that?". But then with every print or rejoin I was using in my code I had this thought "what if..". Then I started using my experimental implementation, and after some time I believe it's a total must have.
zentrog
@zentrog:matrix.org
[m]

I think this Red version is a little closer to the R2 example

        body rejoin [{
            The } PROCESS_NAME { process sent DISKPART the following commands:

                } mold MARKUP_1 {

            The DISKPART result was:

                } mold MARKUP_2 {
        }]

The direction that the 'delimiters' point around the code parts feels a little odd to me, but I don't know if it's good or bad. You do get accurate syntax-highlighting this way, which is nice.

Gregg Irwin
@greggirwin
Indeed. Users won't have syntax highlighting, more than likely, but this is something we should absolutely consider, as we support people writing more tools to help their users.
hiiamboris
@hiiamboris
Why not have it?