Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Re(3): 'parse-url - where defined?

 [1/13] from: rebol:techscribe at: 31-Jan-2001 10:42


Hi Anton, yes, they are all defined in system/words find first system/words 'some-newly-defined-word (even words defined in use contexts). Elan Anton wrote:

 [2/13] from: dockimbel:free at: 30-Jan-2001 18:43


Anton wrote: [...]
> How then, does read-via work?
Oops, i forgot to answer to your second question ! :) 'read-via is defined in the global context, but its value is still bound to the context where it was defined. 'parse-url is defined in the same context, so it has a meaning in 'read-via body. I'm not sure that my explanation is crystal clear, so here's an example code : make object! [ parse-url: func [...][...] set 'read-via func [...][...parse-url...] ... ] ; 'read-via will be globally defined but can call 'parse-url in its body. HTH, DocKimbel.

 [3/13] from: arolls:bigpond:au at: 31-Jan-2001 14:43


Allen, Elan, Nenad,
> Hi Anton, Elan, Nenad, > > That particular parse-url is in the system/view/vid object. > read-via is also > in the same object. (it is not the same as the one in net-utils, though it > does call that one)
How did you discover this? Did you know 'parse-url already or did you have to search? How would you go about searching for a word whose value is defined in some other context? Is there a way of determining which context a word's value is defined in? Is there a way of listing all contexts? Anton.

 [4/13] from: rebol:techscribe at: 30-Jan-2001 21:21


Hi Anton, it's really worth your while to explore the system. Just start at the top-level system object:
>> print mold next first system
look through the list it generates, check the types of the different words contained in the block
>> foreach word next first system [
print [word "has type" type? in system word] ] and then look at what the words that are objects contain. Or, if you're too lazy to do that manually ;-), you can use Bo's system object inspector, which should in rebol.com's archive. It's an interactive tool that lets you explore the system object to a degree. Hope this helps, Elan Anton wrote:

 [5/13] from: larry:ecotope at: 30-Jan-2001 21:21


Hi Anton, Most of the contexts of interest are those associated with objects. I am too tired right now to go into details, but see my previous response for more info. Your questions are well taken. REBOL currently does not have a built-in object browser, which makes exploring objects a bit tedious. And the docs are somewhat behind. You can learn a lot quickly using Nenads help.r which can browse into objects. It works with both Core and View. You can download it at: http://rebol.dhs.org/help.r Just put do %your-path/help.r in your user.r. Then you can start by
>> help system
OBJECT: system WORDS: build -- (Type: date) components -- (Type: block) license -- (Type: string) product -- (Type: word) version -- (Type: tuple) view -- (Type: none) SUB-OBJECTS: console error locale network options ports schemes script standard user words FUNCTIONS: stats -- System statistics. Default is to return total memory allocated. The sub-objects can then be accessed with path notation help system/ports ;for example And so on, drilling deeper and deeper. In this way, you can fairly quickly learn about the words defined in all the accessible objects. HTH -Larry ----- Original Message ----- From: Anton <[arolls--bigpond--net--au]> To: <[rebol-list--rebol--com]> Sent: Tuesday, January 30, 2001 7:43 PM Subject: [REBOL] Re(2): 'parse-url - where defined? Allen, Elan, Nenad,
> Hi Anton, Elan, Nenad, > > That particular parse-url is in the system/view/vid object. > read-via is also > in the same object. (it is not the same as the one in net-utils, though it > does call that one)
How did you discover this? Did you know 'parse-url already or did you have to search? How would you go about searching for a word whose value is defined in some other context? Is there a way of determining which context a word's value is defined in? Is there a way of listing all contexts? Anton.

 [6/13] from: arolls:bigpond:au at: 1-Feb-2001 2:26


Thanks guys, I've got DocKimbel's help patch, and Bo's browse-system.r. I really do need to spend some time poking through the system object more. One question: Is everything contained in the system object? Are all objects in 'system ? All words and objects defined by me - do they end up in 'system somewhere? Anton.

 [7/13] from: larry:ecotope at: 31-Jan-2001 10:29


Hi Anton
> Thanks guys, > > I've got DocKimbel's help patch, > and Bo's browse-system.r. > > I really do need to spend some time > poking through the system object more.
Yes! Currently that is the only way to move to guru status.
> One question: > Is everything contained in the system object?
Short answer: Yes. Actually SYSTEM also has another name REBOL, it is the root of the rebol system.
> Are all objects in 'system ?
Yes, but only those which are built-in at startup appear in the system hierarchy. Of course, you can add to or modify the hierarchy (exercise caution):
>> system/user: make system/user [nick: "sneaky"] >> help system/user
OBJECT: user WORDS: email -- (Type: email) home -- (Type: none) name -- (Type: none) nick -- (Type: string) words -- (Type: none) SUB-OBJECTS: (none) FUNCTIONS: (none)
>> system/user/nick
== "sneaky" So we have actually redefined part of the REBOL system.
> All words and objects defined by me - > do they end up in 'system somewhere?
Yes, but not in the system hierarchy (unless you put them there as above). In one sense of your question, "everything" is in system/words. It is the dictionary or symbol table for the current invocation. The expression first system/words gives a block of all words seen by the scanner whether defined or not, in all contexts. The expression second/system/words gives the corresponding block of *globally* known values (may be unset!). In other words, it only gives a value if the word has a value in the global context. A good example of using these is:
>>source help
To track what you have defined, put this in your user.r antons-stuff: 0 Then at any point in a script or console session,
>>find first system/words 'antons-stuff
returns a list of all the words you have used and their values (in the global context) are the corresponding entries in the block returned by second system/words. May the source be with you, young Jedi ;-) Cheers -Larry PS Things are actually a little more complicated than indicated above, but this will put you on the right track.

 [8/13] from: arolls:bigpond:au at: 31-Jan-2001 2:33


Hi, Looking at source read-via It uses 'parse-url in the second line of read-via's function body. Where does parse-url come from? On the console, parse-url has no value. How then, does read-via work? my system/version == 0.10.38.3.1
>> parse-url
** Script Error: parse-url has no value. ** Where: parse-url
>> source read-via
read-via: func [ {Read a file via the cache. Returns binary. Failure returns error.} url [url! file!] /progress callfunc port-hand /update "Force update from source site" /local path file data purl loc-path ][ if file? url [return read url] if none? purl: parse-url url [return none] loc-path: rejoin [system/options/home/public "/" purl/host "/" any [purl/path ""]] file: join loc-path purl/target path: rejoin ["/" any [purl/path ""] purl/target] either all [not update exists? file] [data: read/binary file] [ data: either progress [read-net/progress url :callfunc port-hand] [read-net url] if data [ if not exists? loc-path [make-dir/deep loc-path] write/binary file data ] ] data ] Anton.

 [9/13] from: dockimbel:free at: 30-Jan-2001 18:14


Hi Anton, Anton wrote:
> Hi, > Looking at
<<quoted lines omitted: 3>>
> On the console, parse-url has no value. > How then, does read-via work?
[...] net-utils/URL-Parser/parse-url You could use my 'help patch to navigate through net-utils and it will allow you to make things like :
>> help net-utils/URL-Parser/parse-url
USAGE: PARSE-URL port url DESCRIPTION: Return url dataset or cause an error if not a valid URL PARSE-URL is a function value. ARGUMENTS: port -- (Type: any) url -- (Type: any) HTH, DocKimbel.

 [10/13] from: rebol:techscribe at: 30-Jan-2001 10:24


Hi Anton, parse-url is defined in net-utils/URL-Parser/parse-url Anton wrote:

 [11/13] from: gjones05:mail:orion at: 30-Jan-2001 13:49


Thanks, DocKimbel, help.r is a nice utility. -Scott ...

 [12/13] from: larry:ecotope at: 30-Jan-2001 12:47


Hi Anton Good question. How does read-via work when parse-url is not a globally defined variable? I thinkyou will find the answer very interesting. The answer is that many functions in both Core and View are defined in the context of objects, and some subset of them is then exported to the global context for general use. This is the current method of encapsulating functions and data. When modules come along this may change. Here is a simple console example of the way this works:
>> ob: make object! [hidden-func: func [x][x * x] set 'sq func [y]
[hidden-func y]]
>> source sq
sq: func [y][hidden-func y]
>> sq 5
== 25
>> help hidden-func
No information on hidden-func (word has no value)
>> >>probe ob
make object! [ hidden-func: func [x][x * x] ]
>>
Because sq is defined in the object ob, it can use hidden-func or any other object variable defined. The object spec block is executed at object creation time. When words are defined by word: blabla, they are defined in the context of the object. When they are defined with set, they are defined in the next higher context level. So mult in this case is global, but it's definition uses the hidden-func in ob. Notice the executed lines of code which do not define an object var are not present after the object is created. Make sense? -Larry PS This approach can be nested at several levels.

 [13/13] from: allenk:powerup:au at: 31-Jan-2001 6:57


Hi Anton, Elan, Nenad, That particular parse-url is in the system/view/vid object. read-via is also in the same object. (it is not the same as the one in net-utils, though it does call that one)
>> f: get in system/view/vid 'parse-url >> source f
f: func [url /local purl][ net-utils/url-parser/parse-url purl: context [user: pass: host: port-id: path: target: none] url if all [purl/target purl/host] [purl] ] To explore Vid a bit more you can print it to a file. echo %vid.txt probe system/view/vid echo none ;Happy reading! Cheers, Allen K

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted