Wiki
Download
Manual
Eggs
API
Tests
Bugs
show
edit
history
You can edit this page using
wiki syntax
for markup.
Article contents:
== Outdated egg! This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for [[/eggref/5/jso|the CHICKEN 5 version of this egg]], if it exists. If it does not exist, there may be equivalent functionality provided by another egg; have a look at the [[https://wiki.call-cc.org/chicken-projects/egg-index-5.html|egg index]]. Otherwise, please consider porting this egg to the current version of CHICKEN. [[tags: egg]] == JSOs [[toc:]] === Introduction This library allows the creation and use of ''JavaScript-style objects'' (JSOs), which are chained association lists that map ''keys'' (which must be symbols) to arbitrary ''values''. When you create a JSO, you can specify a prototype JSO. The recursive sequence of a JSO's prototype, the prototype of its prototype, and so on, is called the ''prototype chain''. If a JSO doesn't contain a particular key, the prototype chain will be searched for it. Modifications, however, are only applied to the referenced JSO, never to anything along the prototype chain. An attempt to look up an unknown key returns a unique value known as the ''undefined value'', which can be tested with {{jso-undef?}}. Note that this value is ''not'' itself a JSO. A JSO is an ordinary Scheme association list with a special key in the first key-value pair. As long as this pair is left undisturbed, they can be searched with {{assq}} and the resulting pairs mutated with {{set-car!}} and {{set-cdr!}}. However, it is safer to use the {{jso-ref}} and {{jso-set!}} procedures instead. === Author John Cowan === License 3-clause BSD === Requirements None === Usage <enscript highlight=scheme> (use jso) </enscript> === Reference ==== Basics ===== make-jso <procedure>(make-jso)</procedure> <procedure>(make-jso PROTO)</procedure> Constructs a new JSO. If {{PROTO}} is supplied, it must be a JSO and is used as the prototype for the new object. ===== jso? <procedure>(jso? OBJ)</procedure> Returns true if {{OBJ}} is a JSO. ===== jso-undef? <procedure>(jso-undef? OBJ)</procedure> Returns true if {{OBJ}} is the undefined value. ===== jso-ref <procedure>(jso-ref JSO KEY)</procedure> Retrieves the value for {{KEY}} in {{JSO}}, or the undefined value if {{KEY}} is not found. ===== jso-set! <procedure>(jso-set! JSO KEY VALUE)</procedure> Sets {{VALUE}} to be the value of {{KEY}} in {{JSO}}; the prototype chain is not searched. ===== jso-remove! <procedure>(jso-remove! JSO KEY)</procedure> Removes {{KEY}} and the associated value from {{JSO}}. The prototype chain is not searched. Therefore, if the same key exists in the prototype chain, it will now be exposed. Attempts to remove nonexistent keys are ignored. ===== jso-proto <procedure>(jso-proto jso)</procedure> Returns the JSO's prototype, or the undefined value if it has none. ==== Special values In addition to key-value pairs, a JSO also has an associated ''special value'', which is the undefined value by default but can be changed to be any Scheme object. ===== jso-value <procedure>(jso-value JSO)</procedure> Returns the special value of {{JSO}}. ===== jso-set-value! <procedure>(jso-set-value! JSO VALUE)</procedure> Sets the special value of {{JSO}} to {{VALUE}}. ==== Copiers ===== jso-copy <procedure>(jso-copy JSO)</procedure> Returns a shallow copy of {{JSO}} that shares the same prototype chain. ===== jso-full-copy <procedure>(jso-full-copy JSO)</procedure> Returns a shallow copy of {{JSO}} including the whole prototype chain. The old and the new JSOs share nothing. ==== Mappers These all accept procedures which take two arguments, the key and the value respectively, and return the new value. ===== jso-map <procedure>(jso-map PROC JSO)</procedure> Returns a new JSO after applying {{PROC}} to each key-value pair of {{JSO}}. The new and old JSOs share prototypes. ===== jso-map! <procedure>(jso-map! PROC JSO)</procedure> Modifies {{JSO}} by applying {{PROC}} to each key-value pair of {{JSO}}. The prototype chain is left undisturbed. ===== jso-for-each <procedure>(jso-for-each proc jso)</procedure> Executes {{PROC}} over all the key-value pairs of {{JSO}}. The returned values are ignored. The prototype chain is not processed. ===== jso-full-map <procedure>(jso-full-map PROC JSO)</procedure> Returns a new JSO after applying {{PROC}} to each key-value pair of {{JSO}} including the whole prototype chain. The new and old JSOs share nothing. Note that there is no {{jso-full-map!}}, on the principle that no standard JSO procedure makes a destructive change to the prototype chain. ===== jso-full-for-each <procedure>(jso-full-for-each PROC JSO)</procedure> Executes {{PROC}} over all the key-value pairs of {{JSO}}, including the whole prototype chain. The returned values are ignored. ==== Method application ===== jso-apply <procedure>(jso-apply JSO KEY . ARGS)</procedure> Applies the procedure (method) which is the value of {{KEY}} in {{JSO}} to {{JSO}}. Any trailing arguments are also passed. ===== jso-apply/fallback <procedure>(jso-apply/fallback JSO KEY FALLBACK . ARGS)</procedure> Applies the procedure (method) which is the value of {{KEY}} in {{JSO}} to {{JSO}}. Any trailing arguments are also passed. If there is no such key, the fallback procedure is invoked instead.
Description of your changes:
I would like to authenticate
Authentication
Username:
Password:
Spam control
What do you get when you subtract 2 from 17?