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

World: r3wp

[Dialects] Questions about how to create dialects

Fork
13-Jan-2010
[509]
Rebmu now has a fledgling homepage/logo/rationale: http://hostilefork.com/rebmu/
Graham
13-Jan-2010
[510]
Basic had one letter variables
Fork
13-Jan-2010
[511x5]
Well, Rebmu has a set of starting definitions for one letter things. 
 So s starts out as the empty string, i starts out as IF.  You can 
redefine these things.
And of course, you can use multiple characters whenever you so wish, 
even using the full Rebol words for things.
I've had some internal debates on questions like whether LN should 
be LENGTH? or if I should make any Rebol identifier that ends in 
a ? also have a ? in it.  These are some tricky questions, but on 
that particular decision (for instance) I've decided that the ? in 
the name is something important to keep.
I'm also thinking that it's better to use three-letters for things 
rather than use letter combinations that don't make sense.  If you 
run out of things RE can be (RETURN, REJOIN, REPEND, etc.) then the 
answer is not to pick one and make it RZ for no reason... but to 
pick the least likely to use in code golf and go to three letters. 
 If this is a problem for any particular challenge they can just 
write (for instance) Rrej at the beginning of the code and then have 
a shorthand.
Of course to make that worth it you would have to use rej more than 
twice:  rejREJ = RrejRr :)
Reichart
13-Jan-2010
[516]
I recall a childrens book from England when I was a child where each 
of the cartoon children in the book spoke in mostly single letters, 
it was something like:

Boy - I C U 
Girl - I C U 2

Boy - R U  HP 
Girl - I M HP

Boy - U R A QT


It was a bit silly, but well made, and they had some MUCH BETTER 
tricks of this than I have given from memory.
Sunanda
13-Jan-2010
[517]
Never knew it as a kid's game, but the Two Ronnies spun it into a 
TV sketch:
http://www2.prestel.co.uk/cello/swedish.htm
Chris
4-Mar-2010
[518x4]
I'm rethinking the behaviour of my 'import dialect (library: http://bit.ly/rebimport
) when working with structured data. At it's simplest form, 'import 
filters a block of key-string pairs based on a supplied set of constraints: 
import [a "1"][a: integer! is more-than 0] == [a 1] ; or none if 
the constraints are not met


There are two nested forms I'd like to support: 1) a continuation 
of key-value blocks [a [b "1"]] and 2) a block of values [c ["b" 
"1" "foo"]]


The first could just be a recursive function or parse call. The second 
needs a little more thought - on the face of it, it could just verify 
the contents conform to a preset group: [ ["a" "b"] contains some 
of ["a" "b" "c"] ] (or any of), which'd be fine for validating web 
form input (eg. multi-select list), but would rule out, say, a JSON 
block containing objects (as key-value pairs).  I'm trying to figure 
out if this is overkill or a genuinely useful way of validating structured 
data...


Then there's ["1" "2" "3"] <- be nice to validate as [some integer!] 
or [some integer! | decimal!]. I don't want it to be overly complex, 
but it should at least be useful - anyone have any conventional cases 
for validating a block of strings?
I should clarify that this is mainly used for validating user input.
For example ["1" "20" "46"] might represent options where input requested 
integers between 1 and 50.  Successful validation would return [1 
20 46] whereas ["1" "foo"] would fail as foo is not an integer.
import [opts ["1" "20" "46"]][opts: block! [integer! is between 1 
50]]
Anton
27-May-2010
[522]
I'm doing a filtering dialect facing similar problems. 
Examples:

[msg-id] = [ 10 .. 50 ]  ; msg-id must be between 10 and 50.
[msg-id] = [ .. 50 ]  ; msg-id must be any number up to 50.
[msg-id] = [ 50 .. ] ; msg-id must be 50 or beyond.

[group] = [ "Dialects" ]  ; group name must be "Dialects"
[msg] = [ .. "import" .. ]  ; message text must contain "import"

[msg] = [ all [[ .. "import" .. ] [ .. "dialect" .. ] ] ]  ; message 
text must contain "import" AND also contain "dialect".

[user] = [any [ "Chris" "Anton" ] ]  ; user name must be any of "Chris" 
or "Anton"
Fork
18-Jun-2010
[523x7]
A "code golf" question on StackOverflow caught my attention yesterday, 
and especially the frustrating ability of perl to win these competitions 
with utterly disgusting code which is unmodifiable with the slightest 
change in spec motivated me to resurrect my rebol dialect for code 
golfing.
My goal is to write "obvious" code in the Rebmu dialect which defines 
primitives and has structure that makes the perl stuff look like 
the backwards garbage it is, and still beat them on character count.
Here in the connect-the-dots problem challenge, I use the Rebmu dialect 
to best the winning perl solution (at the moment) http://stackoverflow.com/questions/2527477/code-golf-connecting-the-dots/3066878#3066878
AltMe put a wacky thing in that link, I'll try again
http://stackoverflow.com/questions/2527477/code-golf-connecting-the-dots/3066878#3066878
Nope, it's just going to screw up the link.  Well that's an argument 
for another time, but here's the link to the overall question and 
you can find my solution: http://stackoverflow.com/questions/2527477/code-golf-connecting-the-dots/
Anyway, if you look at the active community of people who like to 
tinker in code golf, I think they're freaky and obsessive enough 
to perhaps appreciate that Rebol is not only terse, but powerful 
in a generic way.  Note the solution from the guy solving this dot 
connection problem on the commodore 64 in screen memory.  Well, trying 
to solve, it fails on edge conditions
Sunanda
18-Jun-2010
[530]
The link is probably fine. It's a problem with View that AltME inherits. 
Some of us will see it fine, others see it a little screwed. Resizing 
the window can make the problem go away. Usually the link is clickable.
Good luck with converting the golfers!
Fork
18-Jun-2010
[531x2]
Well it's more fun if I'm not doing it alone!!  Note that Code Golf 
answers are wikis, and rebmu is quite easy for Rebol programmers 
to grasp, easy to improve--I think it could be a showcase that might 
get the language in front of "fringe"/"outlier" developers.  (And 
earn perhaps a bit more respect than RebolTutorial's questions, though 
I will say that the visibility he's given by doing Q&A on a modern 
medium is better than nothing...any publicity is better than no publicity, 
the popularity of a tag in sheer number counts is rather important.)
(Being forced to fire up a VM that is willing to run AltME, having 
it mangle my links, and be unable to do "shift up" and have my entire 
line selected or get a right click menu is... well, I'm a sympathetic 
audience, but there's just no comparison to how slick StackOverflow 
is.)
Anton
18-Jun-2010
[533]
Fork, those code golf challenges are interesting, and I'm glad you're 
working on it.

I came up with a method for rendering links perfectly in an AltME-style 
display.

http://anton.wildit.net.au/rebol/doc/overlaid-hyperlink-text-face.r


It's a pity that AltME hasn't been improved with this method. If 
I had access to AltME message display code I could work it in.
Steeve
18-Jun-2010
[534]
Interesting challenge, I will live the evening trying to find something...
Gregg
18-Jun-2010
[535]
Fun stuff Brian.
Maxim
18-Jun-2010
[536x2]
Fork, you should make a sort of white paper on the power of Dialecting 
in REBOL using Rebmu as a reference.  Your language shows just how 
powerfull REBOL's Domain Specific Language capabilities are. Its 
a result of applying dialecting to a very specific Domain, but its 
still pretty much General Purpose .


I think that If its well written, without bias and personal opinion 
on REBOL itself,  it would make the cut for a nice article on REBOL.com's 
web site as an article on the subject.


its just my POV, but marketing information on this, with factual, 
non-trivial, examples is very scarce on the REBOL web site.  I think 
Carl would welcome such a complete example.  you've litterally transformed 
the semantics of the language, yet can still interpret it within 
REBOL.
maybe not the semantics as much as the syntax, but its such a different 
approach that its sort of a blur between both IMHO.
Fork
18-Jun-2010
[538x5]
@Maxim: I've tinkered a little with the semantics, but tried to make 
it so that the abbreviated Rebmu primitives only extend the reactions 
to datatypes which Rebol currently throws errors on.  For instance, 
the letter "e" is mapped to "either-mu", which can handle things 
like constants or functions in the clause block.
Hence you can do things like pEf{Hello}{Goodbye} and get the effect 
of PRINT EITHER F [{Hello}] [{Goodbye}]
Such a feature would be too error-prone in an ordinary Rebol program 
to be worth the savings, but it is essential in shaving off characters
EITHER-MU and its bretheren are factored into what is called the 
"mulibrary.r", which can be used independently of Rebmu.  Though 
you never would.  :)
In my opinion, standardizing Rebmu would be far wiser than decisions 
in Rebol/Core like defining Q to be QUIT (I've pointed out how accidents 
involving this make Rebol seem like it crashes, like when you do 
APPEND [N O P] Q and forget the quote mark on Q).
Fork
22-Jun-2010
[543x5]
I have been writing Rebmu programs in actual Rebmu, as opposed to 
writing them in Rebol and then translating, as a test of how "bad" 
it is: http://github.com/hostilefork/rebmu/tree/master/examples/
As I predicted, it's actually not so bad.  Especially when you can 
break into native Rebol at any point if you want to debug (so long 
as you use lowercase!)
Originally I had it breaking out symbols like - and + in such a way 
that they would cause token breaks, like [a-b] would go to [a - b]. 
 But not only did that cause issues with common naming conventions 
(to-block, etc) it also wastes a lot of two-character tokenspace. 
 So now [a-B] and [A-b] become [a- b], [A-B] becomes [a-b:], [a-b] 
stays [a-b].
There's an exception for runs with multiple characters in this class 
to make programming with ++, --, etc easier.  If multiple characters 
in this class appear in a row then they split the token.  [a++B] 
=> [a ++ b]     [A++b] => [a: ++ b]    ...but...   [A++B] => [a++b:] 
  [a++b] => [a++b]
I also backed of on overwriting the definition of "IF".  The letter 
"i" now starts off mapped to "II" (which stands for "iiiiiiif...."). 
 Similar rationale for "oo" as "ooooor..." which is the non-infix 
version, since infix is useless for code golf
Fork
24-Jun-2010
[548]
Just checked in Rebol 2 compatibility for Rebmu: http://github.com/hostilefork/rebmu/commit/eed98b9570ce957ca248dfd6c67b976ec651beb4
Fork
25-Jun-2010
[549]
I didn't know Rebol 2 didn't have a "continue".
BrianH
25-Jun-2010
[550]
Yeah, and it can't be backported as mezzanine either (tried already). 
I'll request a native.
Fork
25-Jun-2010
[551x3]
I should start a Rebmu quotes page for what people say when I send 
it to them.  "Reading the hourglass solution at first threatened 
to give me a brain aneurysm, but actually after reading this I now 
see you were up to with 'mushing'.  Clever!"
I thought of writing a "derebmu" which converts things like "is" 
into "insert" just as a teaching tool.  I now realize that it's essential 
to have this functionality for things like parse, which are dialects 
in their own right and look at the literal words.  Hence Rebmu's 
PA for parse will have to take its rules argument and derebmu the 
block before execution.
Which leads to the question of why map the words in the do dialect 
at all, and not just derebmu the whole thing before execution.  (I 
think it's just a different way of thinking about what to do with 
the word map, not a tremendously big deal.)
Gabriele
26-Jun-2010
[554]
you can use ALIAS to "change" the words used by PARSE or any other 
dialect.
Fork
26-Jun-2010
[555]
@Gabriele: BrianH says alias is dooooomed.  But he seems to have 
alternatives in mind.  Hopefully something will exist allowing one 
to give names words in such a way that they pass equality tests despite 
different spellings... that would be a huge enabler for international 
markets, as I know of no text-based interpreted language able to 
cater to people in their own tongue the way Rebol can.
Ladislav
26-Jun-2010
[556x2]
Fork, you are right, that REBOL allows internationalization. Problem 
is, that there actually is no demand for internationalization of 
the Do dialect, so it would make sense mainly in other dialects.
Since English is not my native language, I have experiences with 
internationalization myself dating back to 1978, but the main result 
is, that such languages as the Do dialect e.g. are better when not 
internationalized.
Gabriele
27-Jun-2010
[558]
I agree with Brian and Ladislav that "internationalization" of a 
programming language makes no sense at all. Not sure why only some 
americans think it does. :-) ALIAS may not be there in R3 but I'm 
not sure why you should be worried about R3 at this point; but in 
that case you can do the compilation on R3 and use ALIAS in R2, so 
I don't see it as a big issue even if you want to worry about R3. 
:)