World: r3wp
[Core] Discuss core issues
older newer | first last |
JeffM 11-Apr-2006 [3932] | Not sure the best forum to put this on (to where Carl will see it). Are there plans in the future for actual bit operations besides and/or/xor? RIght now, bit shifting, rotating, etc. are extremely painful (and slow compared to what they should be) to do. |
Gabriele 11-Apr-2006 [3933] | rebcode supports shifting; not sure if it makes sense to have a native too, maybe yes. |
JeffM 11-Apr-2006 [3934] | shifting is a very basic operation. I don't understand how it couldn't be part of the core, native functions. The same could be said of AND and OR, and just make them logical operators instead of bitwise. |
Gabriele 12-Apr-2006 [3935] | well, shifting is very lowlevel, and there are not many use cases outside of rebcode. |
JeffM 12-Apr-2006 [3936] | I disagree, but that's fine. I imagine the majority of those using REBOL are using it for non-low level things. I just don't happen to be one of them. REBOL is a great language for making domain specific languages, and many DSLs would benefit from a little more low-level control. |
Henrik 12-Apr-2006 [3937] | I have to disagree as well. I've bumped into a few examples where bit-operations would be very nice to have, if you want to use REBOL for prototyping bit-operations in another environment. Afterall we can create bitsets, why not allow full manipulation of them? |
Gregg 12-Apr-2006 [3938x3] | Well, you can write your own; if just prototyping, the speed isn't critical (we did 160 bit math for Maarten, using bitsets, at one point). That said, if you can use a version with rebcode, just wrap a mezzanine around the ops. That said, I wouldn't mind having standard SHIFT and ROTATE funcs that can operate on integer, or series values. Bit ops are also necessary for implementing certain algorithms. |
Here are prototype funcs for SHIFT and ROTATE (plus a couple supporting funcs). Is it worth some time to come up with good ones and submit them for inclusion in R3? | |
; used in SHIFT below dup: func [value len [integer!] /local type] [ type: either series? value [value] [either char? value [""] [[]]] head insert/only/dup make type len value len ] ; used in SHIFT below make-blank-value: func [type] [ any [ attempt [make type 0] attempt [make type ""] attempt [make type []] attempt [make type none] ] ] ; The new PAD/JUSTIFY func might be used to implement this as well. shift: func [ "Shift values in a series; length doesn't change." series [series!] /left "Shift left (the default)" /right "Shift right" /part range [number!] "Shift this many positions" ; TBD series! support? /with fill "Fill vacated slots with this value" /local pad ][ range: any [range 1] if any [empty? series 0 = range] [return series] pad: dup any [fill make-blank-value last series] range either right [ head insert head clear skip tail series negate range pad ][ append remove/part series range pad ] ] rotate: func [ "Rotate values in a series." series [series!] /left "Rotate left (the default)" /right "Rotate right" /part range [number!] "Rotate this many positions" ; TBD series! support? /local offset pad ][ range: any [all [range range // length? series] 1] if any [empty? series zero? range] [return series] either right [ offset: does [skip tail series negate range] pad: copy offset head insert head clear offset pad ][ pad: copy/part series range append remove/part series range pad ] ] | |
Anton 12-Apr-2006 [3941x3] | I am trying right now to write a file to an FTP server. What I would like to do is: - open the port - try to write the file - if that fails, create the parent directory if necessary - try to write the file again - close the port |
The difficult part is keeping the port open. | |
... and I have my head deep in FTP handler... :) | |
Anton 16-Apr-2006 [3944x2] | Ah... figured out how to do that :) The solution is to disable close-on-fail in the handler, so that a failure in open does not close the ports. This allows the command port to be reused for other commands, such as make-dir. |
Now to make it nice... | |
Graham 16-Apr-2006 [3946] | Anyone know how to write to the parallel port ? |
PeterWood 16-Apr-2006 [3947] | I don't know if this will help: http://www.rebol.org/cgi-bin/cgiwrap/rebol/ml-display-thread.r?m=rmlGBVQ |
Graham 16-Apr-2006 [3948] | Gregg says write %//prn .. I'll give that a go. |
JeffM 17-Apr-2006 [3949] | With image/rgb I can get all the RGB (24-bit) data. With /alpha I can get all the (8-bit) alpha data. Is there one to get RGBA (or ARGB) so the alpha data is interleaved with the RGB data (32-bit)? |
Anton 17-Apr-2006 [3950] | Try to-binary logo.gif |
JeffM 17-Apr-2006 [3951] | So simple -- like most things with REBOL. Don't know why I didn't try that. Thanks. |
Anton 18-Apr-2006 [3952] | Not everything is simple - yet... |
JeffM 18-Apr-2006 [3953] | Like bit shifting. I do appreciate Gregg's functions. However, when something that boils down to a single instruction in hardware requires 6 lines of code and multiple function calls, something is wrong. ;) |
Henrik 18-Apr-2006 [3954] | indeed why bit shifting is needed, at least as built in mezzanine functions |
Graham 18-Apr-2006 [3955x4] | Hmm. Does 'send have a forward option? |
ie. forward an existing email? | |
how to bind this correctly ? | |
>> b: { (blue)} == " (blue)" >> compose to-block b ** Script Error: blue word has no context ** Where: halt-view ** Near: blue | |
Volker 18-Apr-2006 [3959] | Oh, 'to-block does still not bind? good to know. Use 'load . |
Graham 18-Apr-2006 [3960x2] | Can't use 'load as other stuff in the block. |
will cause errors. | |
Anton 18-Apr-2006 [3962] | Ye must bind to an example worde, as it is written in the olde texte. |
Graham 18-Apr-2006 [3963x2] | need to get this working for my postscript dialect to be able to use rebol colours |
instead of tuples | |
Gregg 18-Apr-2006 [3965] | Can you use REDUCE/ONLY? |
Graham 18-Apr-2006 [3966x5] | let me try. |
same problem | |
this is what I want to do | |
{ font (red) } => [ font 255.0.0 ] | |
It may be that I have to include the colour words in my parser. | |
Ingo 19-Apr-2006 [3971] | Do you mean like this? >> b: "(blue)" == "(blue)" >> compose bind to block! b 'white == [0.0.255] You just have to give any word from the same context to bind ... so inthis case any word from the global context (i.e. system/words). The only point to be aware of: If all this happens in a different context, and you happen to have a word named 'white in this context, then you have to use another word. |
Graham 19-Apr-2006 [3972x2] | hey thanks Ingo! |
Anyone written a fetchmail in Rebol? | |
Gabriele 19-Apr-2006 [3974x2] | does send have a forward option - maybe you are looking at RESEND |
at = for | |
Graham 19-Apr-2006 [3976] | ahh.. a new function :) |
Henrik 19-Apr-2006 [3977] | this is probably outside of core and more at the OS level, but it would be nice to somehow check if a script is already running via LAUNCH, to make sure it's only launched one instance at a time. Is this possible? |
Anton 19-Apr-2006 [3978] | maybe try to launch a dummy script and catch the error. |
Henrik 19-Apr-2006 [3979] | another thing could be to have a masterscript running and let the other scripts report to it via LNS, but that's not very elegant... |
Gregg 19-Apr-2006 [3980] | You could use a semaphore of some kind (port/file). |
Anton 19-Apr-2006 [3981] | - the original script will be able to launch the dummy script and thus no error - the launched script will not be able to launch the dummy script and thus an error |
older newer | first last |