r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Rebol School] Rebol School

Geomol
2-Jul-2011
[3483]
Assumably because the opinion was/is, that commas make programs less 
readable. I see no other reason.
Janko
2-Jul-2011
[3484x2]
I see it absolutely cruicial that there aren't commas between elements 
[ 1 2 3 ] NOT [ 1, 2, 3 ].. but this has nothing to do why , couldn't 
be a valid word of a dialect for example if . ` (for example) are 
IMHO
(I suspect it's used somewhere, but I don't see it .. like % or $ 
is not a valid word since they are part of file / money format ( 
not that parser couldn't be made a little smarter and still allow 
it))
Oldes
2-Jul-2011
[3486]
Good question... I was asking as well long time ago http://www.rebol.org/ml-display-message.r?m=rmlDRXJ
BrianH
2-Jul-2011
[3487]
Geomol, you are the winner! That is the official reason. Plus, ,0 
is the same as 0.0 since , can be used as a decimal separator.
Janko
2-Jul-2011
[3488x4]
so any program that has , anywhere is ugly so we ban them.. it's 
no use in complaining, but that doesn't make sense to me.
now my dialect that consumes sql has dots instead of commas [ select 
user.id . user.* from user where id = #myid and name = #name ] .. 
I will surviwe but I will hardly impress any geeks to rebol with 
it as I otherwise could :)
Oldes, I'm on linux where I can't copy poaste that url from altme 
or click it (I don't know why linux doesn't fix dual copy paste and 
istead focuses of various fancy stuff)
So I will reply later when I can
Geomol
3-Jul-2011
[3492x2]
If comma is allowed as word, decision has to be made, what to do 
with things like ,0 as Brian point out. Either anything starting 
with a comma should be words (easy to implement, but might give unpredicted 
result to users trying to writing decimals starting with a comma) 
or a special rule should be made, so it's a decimal, if the comma 
is only followed by digits, else it's a word (harder to implement).
You also need to handle things like:
,000'000e+4
which is simple 0.0 today.
Henrik
3-Jul-2011
[3494]
To me, not having comma is a problem in that certain types of data 
become much harder to load.
Endo
3-Jul-2011
[3495x3]
This is also strange:
b: to-block ";"
length? b
== 0
even:
b: to-block ";;;;;;;"
I think these issues are related to parse, as coma and semicolon 
are default separater for parse.
Henrik
3-Jul-2011
[3498]
actually not strange, since to-block converts the string into REBOL 
data, so it's interpreted as an inline comment. I think the behavior 
is correct.
Endo
3-Jul-2011
[3499]
I see, that's correct. I missed that semicolon is for commenting.
Henrik
3-Jul-2011
[3500]
TO-BLOCK can be seen as a cheap version of LOAD, AFAIK.
BrianH
3-Jul-2011
[3501]
Much cheaper on R3 than R2 - LOAD does a lot of work. Note that TO-BLOCK 
doesn't bind any words in the resulting block, which can come in 
handy sometimes.
Endo
3-Jul-2011
[3502]
thanks, I would I ask what is the difference :)
Gregg
3-Jul-2011
[3503]
TO BLOCK! is much safer on untrusted data as well.
Endo
3-Jul-2011
[3504]
what is risk if I use load?
Gregg
3-Jul-2011
[3505x2]
The comma being disallowed as a word does mean you can't use it literally 
i true dialects, but that doesn't prevent you from writing a DSL 
and using string parsing. There have to be lines drawn somewhere.
LOAD used to evaluate headers aggressively, though I don't think 
it does any more under R2. I'm not sure about R3, but I imagine Brian 
has made sure that's safe.
Izkata
4-Jul-2011
[3507]
Janko: If you right-click the URL, it says "Copied to clipboard" 
- it means the X clipboard, which you paste from in Linux by using 
middle-click
Janko
4-Jul-2011
[3508x7]
Izkata: wow .. it works! :)
Oldes: I read the discussion on mailing list. Obviously I agree with 
you (in fact our reasoning is like copied:)
Gabriele interestingly subverted your reasoning by "you can't expect 
REBOL to be able to parse into REBOL values any syntax", but that 
is not the reasoning here :) . Reasoning is simple why rebol isn't 
more consistent and
(pressed the submit by accident).. reasoning is:
If consistency good?
if . is word why isn't ,?
you mentioned that it's because:
>> ,012
== 0.012

but that fails since this also works :)
>> .012
== 0.012
but I know there are more prominent things to change/fix (if any 
will get fixed at all) that I don't realistically expect anything 
changed about this in near future (but that sql dialect would be 
much cooler if it werent for , exception)
Gabriele
5-Jul-2011
[3515x3]
index.html is a useful word, index,html is not.
there has to be a place where you draw the line... will you ask for 
$ next? what about #? What about ' ? or : ? or even ; ?
some characters are reserved for a reason. if you're parsing another 
language, use string parsing. LOAD is supposed to parse REBOL, not 
other languages.
Geomol
5-Jul-2011
[3518]
' can be used in words like:

>> can't: 42
== 42
>> can't
== 42

Some would argue, comma is kinda the same.
Endo
5-Jul-2011
[3519x2]
there is a behaviour difference for LAST function on blocks and lists:
>> b: next next [1 2]
>> last b
** Script Error: Out of range or past end  ;which is ok

>> a: next next make list! [1 2]
>> last a
== 2

But it is not same for FIRST
>> first a ;(or first b)
** Script Error: Out of range or past end ;same for both.
>> a
== make list! []
>> last? a
== false
Maxim
5-Jul-2011
[3521]
I'd say its a bug with the list! datatype.
Endo
5-Jul-2011
[3522x3]
I guess so, because reverse is changing the internal position also:
>> a: make list! [1 2 3]
== make list! [1 2 3]
>> reverse a
== make list! [3 2 1]
>> a
== make list! [1]
it goes to last item in the list. But it doesn't work like that for 
block! values.
>> b: make block! [1 2 3]
== [1 2 3]
>> reverse b
== [3 2 1]
>> b
== [3 2 1]
There is a bug report on Rambo for reverse on list!
http://www.rebol.net/cgi-bin/rambo.r?id=4420&
Gabriele
6-Jul-2011
[3525x3]
Geomol, right, so, should we also allow # inside a word? Why not 
allow even [ then?


You have to draw a line somewhere, both to simplify the parser, and 
so that the language is readable. The , has a special meaning in 
basically every language, so it's hard to know what the consequences 
of allowing , would be, even assuming the parser is not affected 
by it.
ie. imagine having:

    f (a,b + c,d)

I suspect that'd confuse the hell out of most people.
You could trivially change the parser in Topaz to allow [ and ] inside 
words, and then write something like:

   a[b c]d


but, is that a good thing? So, what's the actual purpose of allowing 
a,b to be a word? So far, the only purpose has been "to parse other 
languages as if they were REBOL". That's not a good purpose, because 
they are *not* REBOL. If you need to parse other syntax, you need 
string parsing. block parsing is for REBOL dialects.


The only sensible reason I can imagine for , to be a word would be 
to use it as an operator so that:

    a , b

means

   also a b


but that has the same readability problems of using . as a "end of 
command marker" in dialects. a nice idea in abstract, but terrible 
in practice.
Janko
6-Jul-2011
[3528x3]
Gabriele: this discussion, at least from my side is totally futile. 
Futile in more than one way. 1 I am nobody in rebol-lang and nothing 
will change because of my oppinion. 2. it's a fact you are 10x better 
rebol programmer (and probably general programmer) and I know it, 
so there can even be no ego-goal here where I can prove I am more 
right than you (eg. smarter) :)
I can just take it as a game, and land some easy punches on places 
you exposed up-there :)

for example, you mention drawing the lines:
- I prefer consistency
easier parser
- consistend languages are often easier to parse 
various cases where it might look wierd
- f (a.b + c'd)  ~ is this better? this is valid now :)

allowing

- I like languages where creator makes a conceptually focused, clear, 
expandable, consistent "engine" and we can grow and combine that 
beyond what language maker was able to initially imagine.


This Guy (:)) talks about something like this: http://video.google.com/videoplay?docid=-8860158196198824415


REBOL is one of very few languages where this actually is possible, 
another language like this is Factor.


You ask if this could be a word a[ . And in Factor this is the case, 
and they also found a concrete use for this specific case. It's been 
more than year so I have to check where I have seen it. (Factor has 
compilation stage (live compilation too) so they have compile time 
macros where they can extend syntax in various ways).
I know they use it in peg parser [[ ]] means "special" block, but 
it's all done on the Library level
Maxim
6-Jul-2011
[3531]
the use of weird constructs is something very usefull in macros. 
 


In C, I'd love to be able to provide more expressive macros, but 
the language still expects macros to be defined as valid C so its 
very hard to extend the syntax or semantics of C.
Janko
6-Jul-2011
[3532]
http://docs.factorcode.org/content/article-fry.html-- example where 
they use '[ parsing word 

http://paste.factorcode.org/paste?id=1723-- example of peg dialect

http://docs.factorcode.org/content/word-H%7B%2Csyntax.html -- I couldn't 
find the samples with [ I was looking for but I found more basic 
samples where they use H{ word to start hashtables V{ vectors and 
so on..

- about easier parser ~ consistency: 

afaik , and . are only used in decimals and they behave the same 
,001 == .001 so it means if , wasn't forbidden parser code would 
be the same for both, so it would be simpler


Factor can use any character as part of the word because it has a 
simple rule that every word must be separated with a space. Which 
is one thing I would love in a rebol-like language, because it brings 
clearness to coding and simplifies parser.