REBOL 3.0

Comments on: What is and is not a series

Carl Sassenrath, CTO
REBOL Technologies
13-May-2009 15:26 GMT

Article #0200
Main page || Index || Prior Article [0199] || Next Article [0201] || 6 Comments || Send feedback

The series! typeset is used to define the argument types for a variety of functions.

Currently, the definition of series! itself comes from deep within the system. It includes various datatypes that use the internal series storage mechanism. However, those datatypes may use different sets of access functions. For example, the bitset! datatype. It does not make sense to refer to the head and tail (or other series-index related functions) of a bitset because they are irrelevant to its operation. So, is a bitset a series or not?

Fortunately, we can resolve this issue because we have precise control over the definition of the series! typeset and the series? type check. The suggestion has been made to remove types like bitset!, image!, and a few others from the series! definition.

That suggestion makes sense, but I wanted to gather your comments on it before proceeding.

Keep in mind that in R3 we can define any typeset we need. So, if we want (for some reason) a special typeset, such as series-based!, we can define that separately, and it requires very little overhead.

6 Comments

Comments:

Steeve
13-May-2009 14:42:05
Instead of removing bitsets from functions, I wish that more functions should return valuable results. Bitsets are underestimated, I use them sometime to store large indexes of integers in R2. It's quite efficient, because each integer take 1 bit in a bitset, so it's fast and takes less memory. Whereas that use case. actions like FIRST or LAST have a real meaning. (like returning the smaller and bigger integers in the bitset) Also, FOREACH could be usefull on bitsets, but it has never be provided. I made this request and remarqs several times in the past using different ways. But i guess noone is using bitsets to store indexes and so they think it's useless to have them working as a true serie.
Brian Hawley
13-May-2009 14:49:28
Given that function arguments are now tested with typesets, there should be no problem removing types from a typeset and adding them to the applicable functions. There is no slowdown either way.

A typeset! in R3 is like an interface in class/interface-based languages. The question to ask is what operations on a type need to be supported, and what qualities the type needs to have.

So for series! the qualities are:

  • A beginning (HEAD, HEAD?)
  • An end (TAIL, TAIL?, LAST)
  • A sequence or order (BACK, NEXT, SKIP, AT, ordinals, PICK, POKE, LAST, SORT)
  • A reference position (HEAD, HEAD?, TAIL, TAIL?, BACK, NEXT, SKIP, AT, FIND, SELECT)
  • Contents (ordinals, PICK, POKE, LAST, EMPTY?)
  • (optional) Modifiability (INSERT, APPEND, CHANGE, REMOVE, CLEAR)

A type can have some of these qualities without the others, but without all of these qualities (except possibly modifiability) the type is not a series.

Objects and maps aren't series because they have no position, and any sequence is illusory. Yet they can still be operated on by some of the same functions, though they often mean something different.

Ports may or may not have a position, depending on the scheme, but that position is an inherent quality of the port, rather than the port reference. Because of this the position functions are modifying for ports, which means that ports aren't series.

The same could be said of bitsets (no position, so shouldn't be series) and dates (no multiplication, so not scalar). If the set of operations isn't covered then we are dealing with a different thing.

Images might be considered to be series, but we need to decide what their contents are (tuples? binary?), and how we define position (only pairs?). We need to discuss what images need to be before we decide that they are series.

Typesets mean that we can now afford to be picky and precise.

Brian Hawley
13-May-2009 14:53:10
Steeve, the reason people aren't using bitsets much in R3 is because they don't work very well yet. The effects of the Unicode changes are still working themselves out. Making bitset! a member of series! wouldn't help at all with that.
Robert
14-May-2009 14:24:18
I agree with Steve. Why remove things if we can make a series! out of it. I can imagine using bitset!, image! etc. as a series. Why not?

Taking some types out IMO creates to much exceptions. Make it as general as possible.

Brian Hawley
14-May-2009 18:55:35
Robert, removing a type from the series! typeset doesn't mean that you can't do the corresponding operations on the type. FOREACH can be used with object! or series!, even though object! isn't in series!.

The real question is not whether you want to do some of the same operations as you can with series - it is whether you want to make sure that all operations that work on series also work on this type. If the type is missing some corressponding concepts, like bitsets and position, then there will be some operations that just won't work.

Having bitset! not be in series! means that you can make FOREACH work, without having to make FORALL or FORSKIP work with position that doesn't exist. It's really no different than what we have now - just better error messages.

Oldes
15-May-2009 15:27:06
I just found that tuple! datatype is not defined as series! I wonder why as I see tuple! just like another visual representation of raw bytes.

Post a Comment:

You can post a comment here. Keep it on-topic.

Name:

Blog id:

R3-0200


Comment:


 Note: HTML tags allowed for: b i u li ol ul font span div a p br pre tt blockquote
 
 

This is a technical blog related to the above topic. We reserve the right to remove comments that are off-topic, irrelevant links, advertisements, spams, personal attacks, politics, religion, etc.

REBOL 3.0
Updated 26-Mar-2017 - Edit - Copyright REBOL Technologies - REBOL.net