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

World: r3wp

[Core] Discuss core issues

JaimeVargas
4-Nov-2005
[2632x2]
You can create your own dialects and grammar. But don't ask for everything 
to be written to your liking.
substring "abcd" [2 .. 3]
BrianH
4-Nov-2005
[2634x2]
; 1-based indexing
slice: func [str start len] [copy/part at str start len]
; 0-based indexing
slice: func [str start len] [copy/part skip str start len]
Fill in with doc strings and [catch] attributes, but the algorithm 
doesn't have to be hard.
Graham
4-Nov-2005
[2636]
which is briefer ?

substring "abcd" [ 2 .. 3 ]

and "abcd"/[2 .. 3]
BrianH
4-Nov-2005
[2637]
The first one, because you can tell what it's doing without having 
to remember more syntax.
Graham
4-Nov-2005
[2638]
I'm not saying that Rebol should be Python, just that it could be 
useful this way.
BrianH
4-Nov-2005
[2639]
How about:  slice "abcd" 2 3
JaimeVargas
4-Nov-2005
[2640x2]
The '.. in my small dialect block is pure syntax sugar and un-necessary 
but easy to remember for some people.
[2 .. 3] hints that it is a range.
Graham
4-Nov-2005
[2642]
yeah

so, "abcd"/[ 2 3 ]
BrianH
4-Nov-2005
[2643]
You don't need a dialect processor and its overhead for what is essentially 
a library function.
JaimeVargas
4-Nov-2005
[2644x2]
That could have more than many menings.
BrianH agreed. I'm just saying that if you want to use other language 
syntax you can always create a dialect.
Graham
4-Nov-2005
[2646]
what's the difference between

series/1

and 

series/[ 1 ]
BrianH
4-Nov-2005
[2647]
I prefer to create a translator for those purposes. Syntactic sugar 
is nice, but I like my runtime code to be on a diet.
Graham
4-Nov-2005
[2648]
Rebol is the translator :)
JaimeVargas
4-Nov-2005
[2649x2]
Brian depends on who is coding and for what purpose? But I am with 
you.
series/1 has clear defined meaning under rebol. series/[1] is undefined.
Graham
4-Nov-2005
[2651]
looks like I'm outnumbered here ... so I'll just withdraw to my corner 
:)
BrianH
4-Nov-2005
[2652x2]
No, REBOL is the runtime. A dialect processor only counts as a translator 
by my standards if the translation is only performed once rather 
than every time the operation is performed. Other languages can have 
tons of syntax because they are compiled.
For that matter, series/[1] violates REBOL data syntax for paths, 
AFAIK.
Graham
4-Nov-2005
[2654]
mere detail
JaimeVargas
4-Nov-2005
[2655]
Graham you want an enhance notation. I think you will do well with 
just a func.
BrianH
4-Nov-2005
[2656]
If your dialect processor is a compiler, then cool. If it is an interpreter 
then its overhead should be as low as possible, at least in proportion 
to the overhead of what it is accomplishing. No dialecting for dialecting's 
sake, at least for production code.
Graham
4-Nov-2005
[2657]
Well, since I use pre-rebol, I guess it could be modified to turn 
the source into what I want.
BrianH
4-Nov-2005
[2658]
See, now you're getting it! :)
JaimeVargas
4-Nov-2005
[2659x2]
But dialecting is good. Ask greg about it.
Some dialects are one time use only others are not for example DRAW
BrianH
4-Nov-2005
[2661]
A lot of the time I do my dialect processing with functors, functions 
that create functions. Sometimes these functors run in pre-rebol, 
some at runtime function creation time. Then the actual work is done 
by the generated functions. This gives me the advantages of dialects 
without the drawbacks. On the other hand, dialects like draw are 
examples of my principle of low overhead in proportion to the that 
of the work performed - the dialect overhead isn't that much different 
to that of a series of function calls in the do dialect.
Gregg
5-Nov-2005
[2662x2]
Adding things like this to path notation hides a lot of compuational 
complexity. Sometimes that's a very good thing, and sometimes it's 
not. And consider what should happen in the case that "my-block/[2 
3]" refers to a two-dimensional array, or a block of name value pairs; 
what should the result be? Something like that fits very well in 
a dialect where the power is leveraged, and the domain is tightly 
constrained. That's where we get power and safety combined.
http://www.rebol.org/cgi-bin/cgiwrap/rebol/ml-display-thread.r?m=rmlGGHC
Volker
5-Nov-2005
[2664]
for shortness, we can use short function-names, sl: :slice  sl string 
2 4 .
If we play with extensions, i propose an operator '..
  s/2 .. 4
Graham
5-Nov-2005
[2665x2]
I suggest we just adopt the Python syntax for slicing strings, and 
accept that this is a dialect for handling string slicing, and not 
2 or more dimensional arrays.
And other one dimensional series.
Louis
5-Nov-2005
[2667]
Is there any way to send email in such a manner as to cause a window 
to pop up on the recepient's email client requesting confimation 
that they received the email?
Graham
5-Nov-2005
[2668]
Yes, and I presume that it is one of the X- type fields.
Louis
5-Nov-2005
[2669]
Do you have a link to some how to info?
Graham
5-Nov-2005
[2670]
nope .. do a google search.
Louis
5-Nov-2005
[2671]
Thanks.
JaimeVargas
5-Nov-2005
[2672]
I think that slice is much more general than the single string domains. 
So if introuduce it needs to be with care. Beside Graham if you are 
using a lot of substrings just create your own func it will make 
your code more explicit to your problem domain.
Gordon
5-Nov-2005
[2673]
Record: [a b c d e f g h i]
foreach mold Record SeriesBlock [
   print record
]

Can someone tell me how to define a block (as in Record) and then 
use that variable in the foreach loop?
Although the array has values, nothing is printed in the loop.

When I remove the 'mold' statement, 'Record' contains just one value 
('a') not 9 (a b c d e f g h i).
DideC
5-Nov-2005
[2674]
>> foreach letter record [print letter]
a
b
c
d
e
f
g
h
i
Gordon
5-Nov-2005
[2675x2]
okay?
Where is the 'block' argument?
DideC
5-Nov-2005
[2677x2]
>> help foreach
USAGE:
    FOREACH 'word data body

DESCRIPTION:
     Evaluates a block for each value(s) in a series.
     FOREACH is a native value.

ARGUMENTS:

     word -- Word or block of words to set each time (will be local) (Type: 
     get-word word block
)
     data -- The series to traverse (Type: series)
     body -- Block to evaluate each time (Type: block)
In this example,
WORD is letter
DATA is record
Body is [print letter]
Gordon
5-Nov-2005
[2679]
I want to use two block arguments.  One for word (value that gets 
set each time) and of course the 'data' block.
DideC
5-Nov-2005
[2680x2]
Oh wait...
you can't with foreach!