World: r4wp
[!REBOL3] General discussion about REBOL 3
older newer | first last |
Geomol 30-May-2013 [2508x2] | I think, you can achieve this with a preprocessor written in REBOL, that parse your scripts and remove the comments, before doing the script. |
Something like: out: clear "" script: { for /*(set)*/ myvar /*starting from*/ 1 /*reach*/ 10 /*use the stepping*/ 2 /* and execute*/ [ print myvar ] } parse script [some [ copy s to "/*" (append out s) thru "*/" | copy s to end (append out s) 1 skip ]] do out | |
GiuseppeC 30-May-2013 [2510] | Geomol, I suppose it is better to have this in the standard language. Do you think it would be difficult to implement ? |
Geomol 30-May-2013 [2511x4] | Not difficult, but is it necessary, and is it rebolish? I haven't done a deeper thought about it, but I would guess, it's as easy to implement as long strings { ... }. |
in the lexer, I mean. After the comment is out, it's done. | |
But I wouldn't recommend it, as it would make rebol scripts look more like the cluster syntax of other languages. | |
And you could probably find other languages with similar, but other syntax, and programmers from those languages would ask for their way and on and on. Do it in a preprocessor! | |
GiuseppeC 30-May-2013 [2515x2] | Geomol, one year ago NickA wrote about a similar feature available in LiveCode. Their language is not so flexible as REBOL, if I remember correctly only native and not user generated functions have accept neutral strings line "at, the, after" to insert in the code. Isn't a REBOL goal to be more human friendly ? We all use descriptions and conections words every day. Inserting it *for free* inside a line, eeverywhere you want, makes a language more readable. |
Obviusly "pros" will like not having them but if they think like a newbye or even like a semi-pro I suppose they will find the usefullness of this imporvemente. | |
Geomol 30-May-2013 [2517x8] | I think, most will find it harder to read with comments in the middle of lines. You can break code over more lines in REBOL, and that way add comments in the middle of lines. |
do [ add 1 ; first number 2 ; second number ] | |
One frind of mine like named arguments to functions in the call of the function. You can probably do that in REBOL easily too. Create a function, that remove the names of arguments, that is sent in a blok together with the values, and then call the real function with only the values. | |
So you could write: do-this [add first-value 1 second-value 2] or something, if that helps. | |
I like to write as little as possible. :) | |
Or maybe better than my do-this example, create a dialect, where all function calls work with named arguments. The parsing then need to look for words, that are functions, find out how many arguments they take and remove the argument names. And do it recursively also. Should be possible, I think. | |
Just a crazy thought to consider: add (1 ; first arg) (2 ; second arg) | |
or add (1 comment "") (2 comment "") Doesn't work in REBOL; but you can do that in World. | |
GiuseppeC 30-May-2013 [2525] | Geomol, I have alway in mind using: for /*(set)*/ myvar /*starting from*/ 1 /*reach*/ 10 /*use the stepping*/ 2 /* and execute*/ [print myvar] and see it in the editor as: for (set) myvar starting from 1 reach 10 use the stepping 2 and execute [print myvar] where the "neutral" words are in different colors. |
Geomol 30-May-2013 [2526] | I see your point, but it just raises some concerns in relation to REBOL. For example, /* is a valid refinement: >> type? /* == refinement! So some might wanna make a shell command in REBOL to be used at the REBOL prompt, that reads /* as all the files in the root directory, like LS /* That will not be possible, if /* is part of a comment. |
Oldes 30-May-2013 [2527] | what about this char: ~ add ~first ~ 1 ~second~ 2 |
GiuseppeC 30-May-2013 [2528] | Geomol, "/* */" is just an example we can use any combinatio which is not so difficult to type :-) (/* */ It come from AREXX ... oh, memories !) |
Geomol 30-May-2013 [2529] | Tilde is an option. There are three function in REBOL using that char, the function variations of and, or and xor. I call those and', or' and xor' in World, so that's a possibility in R3, if people wants. And then tilde can be used in URLs, like: >> type? url://~a == url! I can't judge, if that's a problem, if tilde should be used for comments too. |
Gregg 30-May-2013 [2530] | I don't think REBOL should support it Giuseppe, but you can write a dialect that does. Carl mentioned at one point that he considered allowing "filler" words, but decided against it. I sometimes allow them in my dialects. |
GiuseppeC 30-May-2013 [2531x2] | Gregg, in my scenario I propose filler "comments" and not words. This should not change REBOL language but only commenting. The Editor will be in charge for diplaing these comments in different colors. Adding filler words should be a major change in REBOL. I don't wont to propose something so big. |
Oldes, In my keyboard (italian) there is no tilde key. The only available characters are | (but I ithink it is already use in REBOL. and ^ Another proposal would be to have ";" as alternate ending for the comment other than CR In this way we can have for ;(set); myvar ;starting from; 1 ;reach; 10 ;use the stepping; 2 ;and execute; [print myvar] ;standard comment with stops at the end of line | |
Gregg 30-May-2013 [2533] | Filler values of any kind change REBOL. If you really want to do that, experiment by using tags as comments, strip all tags after loading your code, then DO it. Now see if if really helps people when they use your simple dialect. Can the same be acheived, roughly, with reformatting and end-of-line comments? None of us here can tell you if it is really helpful. It's different, but that doesn't mean better. Using semicolons as an alternate comment end mark is a HUGE change, and not for the better IMO. |
Oldes 31-May-2013 [2534] | Yes, the tilda used in urls is a showstopper. Personaly I don't think that inline comments are necessary and add some readability. I'm fine with current state. |
Geomol 31-May-2013 [2535x3] | Just thinking crazy thoughts loud again: >> comment { ... } >> ;{ ... } >> |
I know, how and why it works as it does today, but should it be possible to: >> comment { ... } 42 == 42 >> ;{ ... } 42 == 42 ; <--- this doesn't happen today. | |
I can't find a problem in it, but I'm not sure, if I like it. | |
GiuseppeC 31-May-2013 [2538] | Gregg, Oldes, it is a feature for people who like it. Having verbose lines really help understand the language but it is not for all. I think about it for new user and to say to the world "you can write human language resembling lines". I was sure that professional rebolers would not find this useful... but it is not useful for them, for us, it is for another part of the world. |
Geomol 31-May-2013 [2539x6] | Yes, I understand that. But some things may not be good to get used to from the start. Because once you're used to that, would you continue using it? Probably you will. So we'll start seeings scripts with comments inside lines. Would it be easier or harder to maintain such code? Would it be easier or harder for other people to learn from such scripts? I'm not sure. Maybe I could implement it in a version of World alpha, so we can see, how it works in practise. |
Even my example in the #World group with comments inside parentheses together with arguments are ugly to me. I'm wondering, if it's a good thing, that you can do such. :) | |
On the other hand, in human written languages, we use comments all the time (like this extra information here). So (as I said before), I'm not sure. :) | |
Should smileys be allowed in a computer language? :D | |
>> -D: does [exit] >> print 42 :-D 42 I'm rambling! | |
>> -O: does [] >> :-O >> -|: does [] >> :-| >> | |
Gregg 31-May-2013 [2545] | Giuseppe, all I'm saying is to experiment first. Dialects are great for that. I'm not against all verbosity, and was reminded recently by an article I read that we can add value by adding information and structure to our programs. And I think the idea of the editor knowing, and highlighting, filler words is great. At this point, and I'm happy to be convinced otherwise, the standard REBOL interpreter should not handle it. Is REBOL more like math or natural language? Would you implement comments the same way if you said "Math"? |
Ladislav 1-Jun-2013 [2546] | #[[Giuseppe REBOL language differs from other languages because you can write "human resembling" code lines. During the past weeks I have thought about a way to make more understandable the language in a simple way now you can write: mypage: read http://www.rebol.com I whish to write: set the variable mypage: reading from http://www.rebol.com ]]Giuseppe Carl really took some "architectural" principles of Rebol from human laguages making it resemble human languages in that respect. However, he did not want to immitate everything. Sorry, Giuseppe, but I must say that you are missing big what is the main principle of advancement relative to other computer languages. It is dialecting and not the ability to write the primitive and verbose "set the variable mypage: reading from http://www.rebol.com" |
GiuseppeC 1-Jun-2013 [2547x4] | Ladislav, I disagree with your (not so) hidden opinion that the feature I proposed is not useful at all. During my early days and even now I find difficult to uderstand REBOL code without "connectors" words which makes a line more descriptive. I agree that dialecting is a big advancement. I also like the opportinity to write "first, second,... last" but adding ";" should be a big change and you should really walk in the shoes of a newbie where reading a line with connector words really makes the difference. |
I think that presenting a line with connectors would let many new developers say "WOW, I can understand this so I can program using this language". Please note I don't want to say that REBOL will be better for all, that it will be more elegant. It is a cosmetic factor which adds readability to the code. Then, when coders get used to the rebol sintax they will naturally drops inline descriptions. | |
Geomol: "is this a good thing ?" Only time and experience will tell. But I am sure that if I write on the top of a web page a full line of code and the If you can understand this, you can write code in WORLD" people will feel they can. | |
*But I am sure that if I write on the top of a web page a full line of code and then "If you can understand this, you can write code in WORLD" people will feel they can. | |
Geomol 1-Jun-2013 [2551] | I have implemented ;{ ... } comments in World. It will be in next alpha to test it. |
GiuseppeC 1-Jun-2013 [2552] | A big reason to give World a try. |
Marco 1-Jun-2013 [2553] | On the same subject, I wish I could write: foreach item in the serie [do something] and I'd like to have single-word comments so it become: foreach item /in-the serie [do something] (the slash is only a possible (?) solution) |
Arnold 1-Jun-2013 [2554] | in-the: function [a [series!]][a] foreach item in-the serie [do something] ??? |
Geomol 1-Jun-2013 [2555] | You could even redefine IN, and get exactly, what's asked for: >> series: [1 2 3] == [1 2 3] >> in: the: func [v] [:v] >> foreach item in the series [print item] 1 2 3 >> |
Henrik 1-Jun-2013 [2556] | It might make it 10% more readable to beginners, but it will make it 90% less usable. |
GiuseppeC 1-Jun-2013 [2557] | Henrik, while I respect your, we have a different opinion. |
older newer | first last |