Too Cool To Not Take Advantage Of: BLANK! Lines

"COMMA!" Had A Puzzling Inflection Point...

So-called "COMMA!" became "BLANK!"

And for something that isn't an antiform, BLANK! is weird

Evaluate a quoted blank and you get... nothing

>> '
==
 ; ^-- (blank!)

>> blank
==
 ; ^-- (blank!)

BLANK! is the invisible thing that you put in TUPLE! or PATH! to have that spot disappear in rendering:

>> tuple: join tuple! [' 'a 'b ']
== .a.b.

>> blank? first tuple
== \~okay~\  ; antiform

But put a BLANK! into a List, and it shows up as... a comma character:

>> append [a b] '
== [a b,]

So BLANK! isn't rendered as a comma: a comma is how a List tells you where the blanks are.

But...What if blank lines in lists...were BLANK!?

e.g. what if a BLANK! inserted into a list...with a NEW-LINE marker...and nothing else on the line... rendered as a blank line.

And what if the loading mechanics preserved it?

>> block: [
      a b 


      c d
   ]
== [
   a b 


   c d
]

>> blank? third block
== \~okay~\  ; antiform

>> blank? fourth block
== \~okay\  ; antiform

:exploding_head:

If there were anything else on the line, but still a BLANK! was there, you'd get a comma to show up.

So with the block above, if you did:

>> insert skip block 3 'x

You would get:

>> block
== [
   a b 
   , x

   c d
]

This Would Be Very Useful In Dialects

Knowing where new lines are is already great (for those taking advantage of it), and knowing where blank lines are will be great too!

I've been limited in the test dialect by not being able to separate tests by blank lines--which is the most obvious separator.

 (
     here is test one
     it has some code
 )(
     here is test two
     we have to indent
     and manage pesky parentheses
 )

Much cleaner to say the tests can be separated by BLANK!.

 here is test one
 it has some code
 
 here is test two
 I don't have to indent
 or manage pesky parentheses

I'm not sure completely sure how I'd rethink the test dialect if I had BLANK!. But you can immediately see that it's a powerful tool.

Best Part: The Hard Work Is Done!

...because BLANK! is already what is behind commas!

  • The EVALUATOR heeds BLANK! as an expression barrier, but throws them out.
  • REDUCE throws BLANK! OUT
  • Things like PACK throw BLANK! out

And if your dialect has been written to handle "commas", it handles blanks...because blanks are what make the commas!

If you care about the difference between "middle of line blanks" and "on their own line" blanks you can deal with the nuance. But if you don't care, then they can be handled the same.

You Could Use Semicolon Comments To Skip Lines

This would still permit your source to have empty lines. But it would bias it such that to get the emptiness, you would have to "opt-out" via a comment:

block: [
    a b
    ; this line intentionally left non-BLANK!
    c d
]

That would not have a BLANK!...

>> block
== [
    a b
    c d
]

If for some reason you wanted a BLANK! and wanted to comment it on the same line :face_with_diagonal_mouth: you'd need a comma:

block: [
    a b
    ,  ; comment on the same line as a lone BLANK!
    c d
]

I'm not sure why you'd do that vs. putting the comment and then leaving an empty line. Nevertheless, that shows you could do it... and it would mechanically give you something that would render as:

>> block
== [
    a b

    c d
]

Too Cool To NOT Do

I'm in.

1 Like

It would be a daunting idea to have this interpretation of BLANK! if not for all the other entangled work.

Vanishability permits pieces of your code to more easily communicate "nothing was there". Hence a mechanic for communicating vanishability (without accidents!) is foundational to allowing something like this to integrate into the system.

This is the linchpin:

https://rebol.metaeducation.com/t/why-comment-vanishes-but-not-eval-of-comment/2563

If you truly understand that, then you understand why a feature like BLANK! has legs in Ren-C.

image

1 Like

3 posts were split to a new topic: Iterating "NEW-LINE" Markers (and BLANK! Lines)