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

[REBOL] Re: On list! inconsistency [was Re: WYSIWYG programming]

From: rishi:picostar at: 2-Nov-2000 21:30

Previously, you (Ladislav Mecir) wrote:
> Hi, > > I would like to say thank you to Rishi for his reply, because otherwise I > would have no chance to see Joel's reply. As my thanks take this: > > insert-item: :insert > insert: func[list [series!] item [any-type!]] [insert-item list item] >
Hi Ladislav. I have tried to use insert the way you mentioned, but for some reason, this does not work. I get the following error: Script: "Queue" (17-Oct-2000) ** Script Error: insert has no value. ** Where: insert-it: :insert insert: func [item [any-type!]] The interesting thing is that the method above works for any other function I have tried (such as remove)...but not insert. It seems that you cannot over-ride insert. I am have included my queue file with the modified insert function the way you have described. Anyone know why this is? Is it a bug in rebol or am I doing something wrong? REBOL [ Title: "Queue" Author: "Rishi Oswal" Email: [rishio--mail--com] Date: 17-Oct-2000 File: %queue.r ] q: make object! [ list: make block! [] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; code in here does not work insert-it: :insert insert: func[item [any-type!]] [insert-it list item] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; this is my code and worked fine ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; must comment out previous insert functions ; insert-item: func [item][insert list item] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; remove-item: func [/local item][ item: last list remove back tail list return item ] peek: does [return last list] size?: does [return length? list] is-empty?: does [return empty? list] reset: does [clear list] print-it: func [ {prints the list. The first item in list is first item entered in list} /local temp-list ][ temp-list: copy list print [head reverse temp-list] ] get: func [ {returns the queue as a list with the first item being the first item inserted} /local temp-list ][ temp-list: copy list return copy head reverse temp-list ] set: func [ {replace current queue with a new one} queue [block!] {block of values with first value being first item insert in list} ][ list: copy head reverse queue ] ] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TEST CODE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; if using my code, please change insert to insert-item ;comment { all queue functions print ["begin all queue functions..." newline] print [{q/insert ["1" 2 3 4.0]} newline ] q/insert "1" print type? q/peek q/insert 2 q/insert 3 q/insert 4.0 print type? first q/list q/print-it print ["q/peek" q/peek] print ["q/is-empty?" q/is-empty?] print "q/remove-item 1 2 3" q/remove-item q/remove-item q/remove-item q/print-it print "q/reset" q/reset q/print-it q/insert 20 q/insert 30 q/insert 40 print "current queue: " q/print-it print ["getting list..."] temp: q/get print temp print "setting queue..." q/set temp q/print-it print ["internal representation: " q/list] print [newline "...end all queue functions"] ;}