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

World: r3wp

[!REBOL3-OLD1]

BrianH
3-Feb-2009
[10496x2]
Henrik, I changed the ticket to be more precise - my job as reviewer 
:)
It would probably be good to have FILEIZE, EXISTS-FILE? and EXISTS-DIR? 
functions in R3, with compatible backports to R2.
Graham
3-Feb-2009
[10498]
what would fileize do that to-file does not?
BrianH
3-Feb-2009
[10499x3]
Done. Here is the R3 and R2 FILEIZE:

fileize: func [
	{Returns a copy of the path turned into a non-directory.}
	path [file! string! url!]
][
	path: copy path
	if #"/" = last path [clear back tail path]
	path
]

Here is the R3 DIR-EXISTS? and FILE-EXISTS?:

dir-exists?: func [
	"Returns TRUE if a file or URL exists and is a directory."
	target [file! url!]
][
	if #"/" <> last target [target: append copy target #"/"]
	'dir = select attempt [query target] 'type
]

file-exists?: func [
	"Returns TRUE if a file or URL exists and is not a directory."
	target [file! url!]
][
	if #"/" = last target [target: head clear back tail copy target]
	'file = select attempt [query target] 'type
]

Here is the R2 DIR-EXISTS? and FILE-EXISTS?:

dir-exists?: func [
	"Returns TRUE if a file or URL exists and is a directory."
	target [file! url!]
][
	if #"/" <> last target [target: append copy target #"/"]
	found? all [
		target: attempt [info? target]
		'directory = get in target 'type
	]
]

file-exists?: func [
	"Returns TRUE if a file or URL exists and is not a directory."
	target [file! url!]
][
	if #"/" = last target [target: head clear back tail copy target]
	found? all [
		target: attempt [info? target]
		'file = get in target 'type
	]
]
Graham, FILEIZE would get rid of any trailing / in the copy, as DIRIZE 
adds any missing /.
The above have been submitted. Time will tell if they are accepted, 
or will be included by default. They work though.
[unknown: 5]
3-Feb-2009
[10502]
Brian, what is the replacement for get-modes in R3?  I'm want to 
see if I can now set creation and modification dates on directories 
yet.  (see if it is now fixed in R3).  I had to scrap a project before 
because of this.
BrianH
3-Feb-2009
[10503x2]
GET-MODES and SET-MODES aren't in R3 yet.
I wonder how they would work with the new port model...
[unknown: 5]
3-Feb-2009
[10505x2]
Well we will definately need those.
I was hoping that more modes would be added in R3.
Pekr
4-Feb-2009
[10507x2]
why do we need special exists functions, when file is a datatype? 
Gee, I hate all those read-* - they are proof there is something 
wrong ...
hmm, according to RebDev chat Carl's post, Carl wants RebDev to move 
to R3. Hence - R3 now boots on Fedora!!! ... although some gfx etc. 
is missing. Carl is looking for help in that area. Good news indeed 
...
GiuseppeC
4-Feb-2009
[10509]
I have just taken a look at the DEMO and it is really amazing. Things 
are done in few lines of code. I feel the power.
Pekr
4-Feb-2009
[10510x2]
I am now confused with latest changes to rebdev. It is becoming total 
mess for me!
I start to lose control where to post what. How do I:

- diplay latest # of messages content? We have L #, but not LM #
-  how do I display particular message, and all its replies?
GiuseppeC
4-Feb-2009
[10512]
We are now again in a grey area ;-)
Pekr
4-Feb-2009
[10513]
Chat system feels good. But if we do add concepts like reply to particular 
message, and system is no more flat, we are not able to easily handle 
it without GUI anymore. Some commands are changed in quick pace, 
some changes don't make sense to me.
BrianH
4-Feb-2009
[10514x2]
As long as the (hopefully useful) messages are being generated, and 
the source files come, chat is doing its job. We can pretty later.
Pekr: "why do we need special exists functions"


Those functions tell us whether the file exists *and* is of the ttype 
we need it to be. Files and directories are used differently. You 
use those functions to make sure that things are what you need them 
to be, so your code will be safer (or at least not crash).


Pekr: "Gee, I hate all those read-* - they are proof there is something 
wrong"


You are correct, that is exactly why the READ-* functions are there. 
They are temporary, until we get the Unicode conversions model finalized. 
Good catch.
GiuseppeC
4-Feb-2009
[10516]
BrianH: I always apreciate your good work and the work of the whole 
team.
BrianH
4-Feb-2009
[10517]
Thanks :)
Janko
4-Feb-2009
[10518x7]
BrianH: You could look at how Factor did "modules" they call it vocabularies 
(and "functions" are words).. I am saying because you said "..... 
Binding order matters in REBOL."
That is the same in Factor, position matters, and the way they did 
is that it adds value as are able to use short general words because 
position defines from which vocab it will be called -- so you avoid 
need to define long words >>addTwoVectors<< .. and you also avoud 
>> module.word 12 + module2.word2 "asd"<<
this is fictional factor example.. not real code and modules:
USING: string math http ;

: plus ( a b -- c ) + ;

USE: vectors

: vec-plus ( a b -- c ) + ;
because + is defined in math plus will use it's + to add two numbers 
and because we put USE: vectors the + in vec-plus will add 2 vectors 
... this is in the same vocab / source code file.. I think they also 
have UNUSE now but I am not sure
( they have USING: for "including" multiple vocabs at once and USE: 
for one)
what I really liked about this (I am not a specialist in factor so 
I hope I am not saying it wrong) but when I was making DB libraray 
for example I could use define very generic words like SELECT WHERE 
UPDATE without thinking if they are defined somewhere else.
kib2
4-Feb-2009
[10525]
Janko : I think you're right (I'm currently learning Factor too).
Janko
4-Feb-2009
[10526]
I am sort of factor traitor :( ... I was doing a very important project 
for me in it and told everyone that I am doing it etc... got relatively 
far, but then by "accident" discovered that there are many practical 
reasons to switch that project to Rebol, so I abandoned factor :/
BrianH
4-Feb-2009
[10527]
Links to web sites would be nice. I suspect that REBOL's situation 
is a little different though, as the binding model is unusual.
Janko
4-Feb-2009
[10528]
technology is a cruel world :) "at the end, there can be only one"
kib2
4-Feb-2009
[10529]
I can understand your choice, Rebol is a good alternative, even if 
I Factor is a very interesting langage to study.
Janko
4-Feb-2009
[10530x3]
http://www.factorcode.org/http://concatenative.org/wiki/view/Factor
this is maybe the good start: http://docs.factorcode.org/..
yes, I don't know about low level things... maybe it can give you 
some ideas..
BrianH
4-Feb-2009
[10533]
Thanks. I had heard of Factor, but not seen it.
Janko
4-Feb-2009
[10534x2]
it's a forth + lisp + haskell sort of language .. it's stack and 
image based
kib2: yes .. both are interesting ... I had a bunch of concrete reasons 
to switch.. basically I didn't want to, but all the indicators were 
in favor of rebol for what I need (I intend to write a blogpost about 
it .. because it's too long to explain here)
BrianH
4-Feb-2009
[10536]
The particular binding order effect that matters in REBOL is that 
"outer" and "inner" scopes are faked with the binding order. Any 
attempts to revise the "inherited" contexts that the code is supposed 
to have, after the code has started running, is unpredictable at 
best and crashworthy at worst - a bad idea in any case. This means 
that if you want to import words from other modules into your code, 
you should do it *before* your code starts running. This means import 
headers, not import funcctions.
kib2
4-Feb-2009
[10537]
Janko: what were you missing exactly ?
Janko
4-Feb-2009
[10538x6]
I don't have a good view into what "binding" is at rebol yet .. I 
imagine a little
kib2 : nothing was really missing in factor ... I live from my coding 
so I have to choose the tools where I think I will fasters with least 
problems and best solve what I need... this was a web-app that needed 
to run on desktop to (so all apache+ XX + mysql) fell of and it gave 
me a reason to make it with factor.
but as I said, it's complicated a little ... I can copy paste you 
the text I wrote to dockimbel when I was explaining him how I started 
with cheyenne few weeks back..
>>>basically I tried cheyenne and rebol for web-apps just by accident 
... one saturday I was ready to work on that project in factor whole 
day and then some hard bug in factor server prevented me from working, 
so because I was in a working mode I started playing with doing some 
other simple idea in ruby on rails (I haven't tried it yet before 
- I don't like frameworks in general) .. after I hit some magic of 
RoR I stopped and then tried cheyenne RSP .. and I made a basis of 
a working app in that afternoon ..  when I tested and saw it also 
performs I was hooked..<<<
in short: Factor is very interesting language but I was amazed at 
how productive I was with rebol + rsp, I need PDF: factor has some 
deprecated bindings to c lib for generating pdf-s, rebol has a dialect 
for that, I need to run in on a desktop standalone: factor can run 
standalone but is more heavyweight, cheyenne server starts and shows 
icon in tray "before I even click it" , I need a tray icon too for 
my app, I found example of it already and it works, in factor something 
like this doesn't exist yet ..
and bottom line is the language , rebol nicely scales al the vay 
from newbie (imagine VB coder) up to advanced user with introspection 
code is data and all , factor is a little more scarry to start with
kib2
4-Feb-2009
[10544]
Janko: the pdf and postscript dialects in Rebol have impressed me 
a lot. Maybe it's possible to build something like LaTeX in Rebol.
Janko
4-Feb-2009
[10545]
I haven't yet digged geep into them , I just looked to see if they 
work .. but yes, they are very nice way to make pdf-s :)