[TYPE] weird return value
[1/18] from: tim:johnsons-web at: 21-Apr-2004 10:29
this is weird:
>> type? /home/http/run/cohen/birds
== /birds
/birds is obviously not a type.
What is happening here?
thanks
tim
--
Tim Johnson <[tim--johnsons-web--com]>
http://www.alaska-internet-solutions.com
[2/18] from: paulporter:buffalotalks at: 21-Apr-2004 14:48
I believe if you put some address info on the front end like:
>> type? C:/home/http/run/cohen/birds
== url!
Or
>> type? http://www.someaddress.com/home/http/run/cohen/birds
== url!
you'll get what your looking for.
HTH;
Paul
--
Linux User Number: 348867
[3/18] from: rotenca:telvia:it at: 21-Apr-2004 21:01
Hi.
> this is weird:
>
> >> type? /home/http/run/cohen/birds
> == /birds
>
> /birds is obviously not a type.
>
> What is happening here?
It is happening that your are writing a line of code like this:
type? /home /http /run /cohen /birds
the "/" starts a refinement! word that ends at the next "/" where starts
another refinement! word.
the last refinement (/birds) is returned at the end of the evaluation:
A confirm:
length? [/home/http/run/cohen/birds] ;== 5
while a path like this gives:
length? [home/http/run/cohen/birds] ;== 1
A path cannot start with "/".
---
Ciao
Romano
[4/18] from: hallvard:ystad:oops-as:no at: 21-Apr-2004 21:07
Hi Tim,
You start with a /, and for some reason, that is recognized as a refinement!, not a path!.
>> type? /home
== refinement!
refinements are (like?) a data type:
>> /home
== /home
But I do agree that type? /home/http/run/cohen/birds should not return /birds.
HY
Dixit Tim Johnson (20.29 21.04.2004):
[5/18] from: greggirwin:mindspring at: 21-Apr-2004 13:24
Hi Tim,
>>> type? /home/http/run/cohen/birds
TJ> == /birds
TJ> /birds is obviously not a type.
TYPE? is looking at /home, and seeing it as a refinement! value. Then
the others are all refinements as well, and you see the value of the
last one returned.
>> reduce [ /home/http/run/cohen/birds]
== [/home /http /run /cohen /birds]
-- Gregg
[6/18] from: maximo:meteorstudios at: 21-Apr-2004 15:19
> It is happening that your are writing a line of code like this:
> type? /home /http /run /cohen /birds
<<quoted lines omitted: 7>>
> length? [home/http/run/cohen/birds] ;== 1
> A path cannot start with "/".
But it should return invalid data or refinement!
-MAx
[7/18] from: joel:neely:fedex at: 21-Apr-2004 14:30
Hello, all...
Consider this:
>> reduce [type? /home/http/run/cohen/birds]
== [refinement! /http /run /cohen /birds]
So each element of the path-looking thingie is treated as a distinct
value, and what gets printed is the last one, just as in
>> type? 1 2 3 4
== 4
Hope this helps!
-jn-
Hallvard Ystad wrote:
> Hi Tim,
> You start with a /, and for some reason, that is recognized as a refinement!, not a
path!.
<<quoted lines omitted: 25>>
>>[rebol-request--rebol--com] with unsubscribe as the subject.
> Prętera censeo Carthaginem esse delendam
--
As we enjoy great advantages from inventions of others, we should be
glad of an opportunity to serve others by any invention of ours;
and this we should do freely and generously.
-- Benjamin Franklin
[8/18] from: maximo:meteorstudios at: 21-Apr-2004 15:38
> > length? [/home/http/run/cohen/birds] ;== 5
> >
<<quoted lines omitted: 4>>
> > A path cannot start with "/".
> But it should return invalid data or refinement!
I meant and invalid data ERROR...
cause doing:
>> type? /dog
== refinement!
so IMHO the return value is erronous. one should not have to do:
if (datatype? type? value) [do something]
whenever they do generic language extensions.
type? is such a core function!!!!!! for dialecting.
type? should raise an error if /a/b/c is considered illegal code
or refinement! if its legal. I can see that it would be usefull for code argument parsing
or refinement sets storing ...
-MAx
[9/18] from: tim:johnsons-web at: 21-Apr-2004 11:41
* Romano Paolo Tenca <[rotenca--telvia--it]> [040421 11:25]:
> Hi.
> > this is weird:
<<quoted lines omitted: 15>>
> length? [home/http/run/cohen/birds] ;== 1
> A path cannot start with "/".
<grin> On linux it does.
tj
> ---
> Ciao
> Romano
>
> --
> To unsubscribe from this list, just send an email to
> [rebol-request--rebol--com] with unsubscribe as the subject.
--
Tim Johnson <[tim--johnsons-web--com]>
http://www.alaska-internet-solutions.com
[10/18] from: tim:johnsons-web at: 21-Apr-2004 11:45
* Gregg Irwin <[greggirwin--mindspring--com]> [040421 11:37]:
> Hi Tim,
> >>> type? /home/http/run/cohen/birds
<<quoted lines omitted: 5>>
> >> reduce [ /home/http/run/cohen/birds]
> == [/home /http /run /cohen /birds]
I am of the opinion that this is a bug.
(again my opinion):
a call to type? should either return a
valid type name or throw some kind
of an exception.
Interesting observation below:
> >> reduce [ /home/http/run/cohen/birds]
> == [/home /http /run /cohen /birds]
tim
> -- Gregg
>
> --
> To unsubscribe from this list, just send an email to
> [rebol-request--rebol--com] with unsubscribe as the subject.
--
Tim Johnson <[tim--johnsons-web--com]>
http://www.alaska-internet-solutions.com
[11/18] from: hallvard:ystad:oops-as:no at: 21-Apr-2004 21:46
Dixit Maxim Olivier-Adlhoch (21.19 21.04.2004):
>But it should return invalid data or refinement!
Should it?
>> a:/ ; url!
== a:/
>> # ; issue!
== #
>> <A<> ; tag!
== <A<>
>> [e--e] ; email!
== [e--e]
Rebol doesn't always check your input for validity. When you pass something to the rebol
console, it is evaluated. Always. /Birds is evaluated and found to be a refinement. So
rebol returns the refinement /birds.
HY
[12/18] from: hallvard::ystad::oops-as::no at: 21-Apr-2004 22:03
Dixit Tim Johnson (21.45 21.04.2004):
> (again my opinion):
> a call to type? should either return a
> valid type name or throw some kind
> of an exception.
Oh, but it does! But on the original line, there was
type? /home/http/run/cohen/birds
Rebol evaluates through the line, but prints to the console only the last value it encounters.
Rebol will pass through like this:
refinement!, /http, /run, /cohen, /birds, ... nothing more? OK, let's return /birds,
then:
== /birds
Like Joel pointed out:
>> type? 1 2 3 4
== 4
integer!, 2, 3, 4, ... nothing more? ... etc.
But I do admit that it is confusing that rebol sees word boundaries where we do not (immediately).
HY
[13/18] from: greggirwin:mindspring at: 21-Apr-2004 14:11
Hi Tim,
TJ> (again my opinion):
TJ> a call to type? should either return a
TJ> valid type name or throw some kind
TJ> of an exception.
It does. See Joel's example:
>> reduce [type? /home/http/run/cohen/birds]
== [refinement! /http /run /cohen /birds]
You mentioned that on Linux, paths can start with a slash, if you're
referring to files, just make it a file:
>> type? %/home/http/run/cohen/birds
== file!
HTH!
-- Gregg
[14/18] from: maximo:meteorstudios at: 21-Apr-2004 16:19
After writing my last mail and reading other posts... I realized that
/a/b/c/d is an illusion.
when it gets loaded, it ALWAYS becomes:
/a /b /c /d even if reduce is not called on it.
>> probe [/a/b/c]
>> [/a /b /c]
probe [[[/a/b/c]]]
[[[/a /b /c]]]
Like Hallvard just noted, chained refinements are all really separate words.
not so obvious!
-MAx
---
You can either be part of the problem or part of the solution, but in the end, being
part of the problem is much more fun.
[15/18] from: tim:johnsons-web at: 21-Apr-2004 13:01
* Maxim Olivier-Adlhoch <[maximo--meteorstudios--com]> [040421 12:38]:
> After writing my last mail and reading other posts... I realized that
> /a/b/c/d is an illusion.
<<quoted lines omitted: 4>>
> probe [[[/a/b/c]]]
> [[[/a /b /c]]]
That's some interesting observations of how paths are handled.
> Like Hallvard just noted, chained refinements are all really separate words.
And by the way, :-) I do know to precede a path with a '%',
but I did think it was some interesting behavior.
thanks folks!
tim
> not so obvious!
> -MAx
<<quoted lines omitted: 4>>
> To unsubscribe from this list, just send an email to
> [rebol-request--rebol--com] with unsubscribe as the subject.
--
Tim Johnson <[tim--johnsons-web--com]>
http://www.alaska-internet-solutions.com
[16/18] from: rotenca:telvia:it at: 21-Apr-2004 23:21
Hi,
> > A path cannot start with "/".
>
> <grin> On linux it does.
> tj
A file! path can start with "/" also in Rebol:
%/home/http/run/cohen/birds ;== %/home/http/run/cohen/birds
and you can also do:
home: %/home
home/http/run/cohen/birds ;== %/home/http/run/cohen/birds
---
Ciao
Romano
[17/18] from: g:santilli:tiscalinet:it at: 22-Apr-2004 13:04
Hi Maxim,
On Wednesday, April 21, 2004, 9:38:03 PM, you wrote:
MOA> I meant and invalid data ERROR...
Nope. Look closer!
>> type? /home
== refinement!
>> type? /birds
== refinement!
No surprise here, right?
>> type? /home
== refinement!
>> /birds
== /birds
No surprise here either, /BIRDS is just returned... right?
>> type? /home /birds
== /birds
Does this surprise you?
>> type? /home/birds
== /birds
Then why should this surprise you? It is the same as above...
>> reduce [type? /home/birds]
== [refinement! /birds]
Regards,
Gabriele.
--
Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer
Amiga Group Italia sez. L'Aquila --- SOON: http://www.rebol.it/
[18/18] from: g:santilli:tiscalinet:it at: 22-Apr-2004 13:07
Hi Tim,
On Wednesday, April 21, 2004, 11:01:49 PM, you wrote:
>> [[[/a /b /c]]]
TJ> That's some interesting observations of how paths are handled.
Well, but that is NOT a path. :-)
>> Like Hallvard just noted, chained refinements are all really separate words.
TJ> And by the way, :-) I do know to precede a path with a '%',
TJ> but I did think it was some interesting behavior.
So is this?
>> type? 1"Hello"
== "Hello"
>> type? 1"Hello"2
== 2
REBOL does not ALWAYS need spaces between values...
Regards,
Gabriele.
--
Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer
Amiga Group Italia sez. L'Aquila --- SOON: http://www.rebol.it/
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted