I'm writing some code that manipulates IP addresses. I would like to give the IP address object a pretty-printable and readable representation. Currently, I'm using a DEFTYPE declaration of (SIMPLE-BIT-VECTOR 32) as my IP address object, and the only way I can think of making something that would be usable with PPRINT-DISPATCH and friends is to create a DEFCLASS or DEFSTRUCT wrapper around the actual bit array.
This sucks and I'd really prefer not to be in the boxing-and-unboxing objects business. Is there a better way?
-- Matthew X. Economou <xenop...@irtnog.org> - Unsafe at any clock speed! I'm proud of my Northern Tibetian heritage! (http://www.subgenius.com)
> This sucks and I'd really prefer not to be in the boxing-and-unboxing > objects business. Is there a better way?
I don't see that there can be. In order to print some object specially the system needs some indication that it is a special object. The type of the object is pretty much it, I think.
* Matthew X. Economou | I'm writing some code that manipulates IP addresses.
A class wrapper around a one-element vector specialized to contain 32-bit integers seems like a good choice. Provide readers and setters that return and accept (respectively) a string, an integer, and four bytes.
| I would like to give the IP address object a pretty-printable and readable | representation.
Simple and easy with a class wrapper.
| Currently, I'm using a DEFTYPE declaration of (SIMPLE-BIT-VECTOR 32)
Why on earth? The overhead of constructing and deconstructing it bit by bit must be enormous.
| Is there a better way?
See `print-object´. Specialize methods on it for your wrapper class.
-- Erik Naggum, Oslo, Norway
Act from reason, and failure makes you rethink and study harder. Act from faith, and failure makes you blame someone and push harder.
> This sucks and I'd really prefer not to be in the > boxing-and-unboxing objects business. Is there a better way?
I don't see how you can specialize on the semantic meaning of an object.. But if what you are really conserned with is printing these IP addresses for human consumption, you can use the tilde-slash format directive:
> >>>>> "Erik" == Erik Naggum <e...@naggum.no> writes:
> Erik> Why on earth [(SIMPLE-BIT-VECTOR 32)]? The overhead of > Erik> constructing and deconstructing it bit by bit must be > Erik> enormous.
> The C mindset on my part. I figured it would make parsing packet > traces easier if I used the on-the-wire formats in memory.
??? Wouldn't the C-mindset version be to use an (unsigned-byte 32)? FWIW, that's not a bad representation, either[*], since CL has much better bit-bashing abilities than C does.
[*] Of course, a thin class wrapper around it is better, because then you have type information attached to the number about what it means.
-- /|_ .-----------------------. ,' .\ / | No to Imperialist war | ,--' _,' | Wage class war! | / / `-----------------------' ( -. | | ) | (`-. '--.) `. )----'
>>>>> "Thomas" == Thomas F Burdick <t...@famine.OCF.Berkeley.EDU> writes:
Thomas> ??? Wouldn't the C-mindset version be to use an Thomas> (unsigned-byte 32)? FWIW, that's not a bad representation, Thomas> either[*], since CL has much better bit-bashing abilities Thomas> than C does.
Aren't (SIMPLE-BIT-VECTOR 32) and (UNSIGNED-BYTE 32) the same thing?
In any case, I was attempting to build an interface that was "zero copy", where the in-memory and on-the-wire (or on-the-filesystem) formats were identical. This is probably an example of premature optimization on my part.
-- Matthew X. Economou <xenop...@irtnog.org> - Unsafe at any clock speed! I'm proud of my Northern Tibetian heritage! (http://www.subgenius.com)
In article <w4od6r4e0wd....@eco-fs1.irtnog.org>, Matthew X. Economou <xenophon+use...@irtnog.org> wrote:
>>>>>> "Thomas" == Thomas F Burdick <t...@famine.OCF.Berkeley.EDU> writes:
> Thomas> ??? Wouldn't the C-mindset version be to use an > Thomas> (unsigned-byte 32)? FWIW, that's not a bad representation, > Thomas> either[*], since CL has much better bit-bashing abilities > Thomas> than C does.
>Aren't (SIMPLE-BIT-VECTOR 32) and (UNSIGNED-BYTE 32) the same thing?
No. SIMPLE-BIT-VECTOR is a type of array, and will have all the usual array overhead (typically a dope vector containing the dimensions and type info). Also, you can only access it a bit at a time. The elements of the array will most likely be packed into a single, 32-bit word, though.
>In any case, I was attempting to build an interface that was "zero >copy", where the in-memory and on-the-wire (or on-the-filesystem) >formats were identical. This is probably an example of premature >optimization on my part.
I'm not sure how you were planning on doing that with the bit vector. Doesn't your input routine need a loop that calls SETF for each bit?
-- Barry Margolin, bar...@genuity.net Genuity, Woburn, MA *** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups. Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
* Matthew X. Economou | Aren't (SIMPLE-BIT-VECTOR 32) and (UNSIGNED-BYTE 32) the same thing?
Not even remotely comparable.
| In any case, I was attempting to build an interface that was "zero copy", | where the in-memory and on-the-wire (or on-the-filesystem) formats were | identical.
You cannot write any integers into bit-vectors other than 0 and 1. You address each individual bit. It is slow and expensive to turn an integer into a bit-vector or vice versa unless you get at the implementation details.
Something tells me you have no running code at this point.
-- Erik Naggum, Oslo, Norway
Act from reason, and failure makes you rethink and study harder. Act from faith, and failure makes you blame someone and push harder.
> I'm writing some code that manipulates IP addresses. I would like to > give the IP address object a pretty-printable and readable > representation. Currently, I'm using a DEFTYPE declaration of > (SIMPLE-BIT-VECTOR 32) as my IP address object, and the only way I can > think of making something that would be usable with PPRINT-DISPATCH > and friends is to create a DEFCLASS or DEFSTRUCT wrapper around the > actual bit array.
> This sucks and I'd really prefer not to be in the boxing-and-unboxing > objects business. Is there a better way?
Defining a class may suck less when you go beyond IPv4.
How do you decide that a structure is around enough to warrant being able to read back in it's printed representation?
Will we have to worry about read dispatch character collisions?
What else is useful to bundle with IP addrs? :netmask :vlsm-bits :wildcard (Is Cisco the only one who uses wildcards?) :gateway :route :dns ? :dhcp - to make it a dynamic variable
EN> Something tells me you have no running code at this point.
Bulent> I have the same hunch. Maybe we ought to point out that Bulent> looking up dpb ldb etc. might be helpful at this point.
Unfortunately, you are both correct. I'll try LDB/DPB and friends, and go from there. I was trying to create an FFI for WinPcap in Corman Lisp, but for now, I think it will be easier if I just try to read in the sniffer traces off the disk.
Thanks for all your help with the bit-bashing.
-- Matthew X. Economou <xenop...@irtnog.org> - Unsafe at any clock speed! I'm proud of my Northern Tibetian heritage! (http://www.subgenius.com)
Barry Margolin <bar...@genuity.net> writes: > In article <w4od6r4e0wd....@eco-fs1.irtnog.org>, > Matthew X. Economou <xenophon+use...@irtnog.org> wrote: > >>>>>> "Thomas" == Thomas F Burdick <t...@famine.OCF.Berkeley.EDU> writes:
> > Thomas> ??? Wouldn't the C-mindset version be to use an > > Thomas> (unsigned-byte 32)? FWIW, that's not a bad representation, > > Thomas> either[*], since CL has much better bit-bashing abilities > > Thomas> than C does.
> >Aren't (SIMPLE-BIT-VECTOR 32) and (UNSIGNED-BYTE 32) the same thing?
> No. SIMPLE-BIT-VECTOR is a type of array, and will have all the usual > array overhead (typically a dope vector containing the dimensions and type
^^^^^^^^^^^
It has been a very long time since I heard this expression :)
Cheers
-- Marco Antoniotti ======================================================== NYU Courant Bioinformatics Group tel. +1 - 212 - 998 3488 715 Broadway 10th Floor fax +1 - 212 - 995 4122 New York, NY 10003, USA http://bioinformatics.cat.nyu.edu "Hello New York! We'll do what we can!" Bill Murray in `Ghostbusters'.
> > >Aren't (SIMPLE-BIT-VECTOR 32) and (UNSIGNED-BYTE 32) the same thing?
> > No. SIMPLE-BIT-VECTOR is a type of array, and will have all the usual > > array overhead (typically a dope vector containing the dimensions and type > ^^^^^^^^^^^
> It has been a very long time since I heard this expression :)
Does this dope in that context mean drugs, dumb or airplane fabric treatment? The Jargon File doesn't have list the term.
>> > >Aren't (SIMPLE-BIT-VECTOR 32) and (UNSIGNED-BYTE 32) the same thing?
>> > No. SIMPLE-BIT-VECTOR is a type of array, and will have all the usual >> > array overhead (typically a dope vector containing the dimensions and type
>> It has been a very long time since I heard this expression :)
>Does this dope in that context mean drugs, dumb or airplane fabric >treatment? The Jargon File doesn't have list the term.
I'm not sure of the etymology, but I suspect it may be similar to the word "doping" when used in the context of semiconductors, which refers to adding extra stuff to material.
In CS, a dope vector is an internal data structure containing information about a user-visible data structure. For an array it contains the type and dimension information; for a CLOS instance the class object and any caches used by the implementation would serve this purpose.
-- Barry Margolin, bar...@genuity.net Genuity, Woburn, MA *** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups. Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
> >>>>> "EN" == Erik Naggum <e...@naggum.no> writes: > EN> Something tells me you have no running code at this point. > I have the same hunch. Maybe we ought to point out that looking up > dpb ldb etc. might be helpful at this point.
OP can also check out CLOCC which has ipaddr-to-dotted and dotted-to-ipaddr; these may already do what he wants.
* Barry Margolin wrote: > I'm not sure of the etymology, but I suspect it may be similar to the word > "doping" when used in the context of semiconductors, which refers to adding > extra stuff to material.
Isn't there a term in some US slang `the straight dope'? I'm not sure what it means (or if it is a term in fact), but I think it's something to do with getting information about something, which would explain te `dope vector' usage.
>>I'm not sure of the etymology, but I suspect it may be similar to the word >>"doping" when used in the context of semiconductors, which refers to adding >>extra stuff to material.
> Isn't there a term in some US slang `the straight dope'? I'm not sure > what it means (or if it is a term in fact), but I think it's something > to do with getting information about something, which would explain te > `dope vector' usage.
> --tim
"The straight dope" is a term, and I understand it to mean "the real information, without any lies or BS". This is likely to be derived from the drug context, where "straight dope" would refer to pure, unadultered material. Which could be rephrased, mixing in the semiconductor metaphor, as "dope with no dope".
Tim Bradshaw <t...@cley.com> wrote: +--------------- | * Barry Margolin wrote: | | > I'm not sure of the etymology, but I suspect it may be similar to the word | > "doping" when used in the context of semiconductors, which refers to adding | > extra stuff to material. | | Isn't there a term in some US slang `the straight dope'? +---------------
One of the dictionary definitions of "dope" is "information, especially from a reliable source" (as in "the inside dope"). The dictionary says it dates back to 1807, and comes from the Dutch word for "sauce" (as in "dip").
+--------------- | ...I think it's something to do with getting information about | something, which would explain the `dope vector' usage. +---------------
Exactly. Typical usage: "Did you get the new dope on the weather?"
By the way, a special case of "dope vectors" are "Iliffe vectors", which are one implementation of multi-dimensional arrays. (See <URL:http://www.cs.man.ac.uk/~pjj/cs2111/ho/node17.html> for more discussion of both of these.)
The ALGOl-60 compiler on the DEC PDP-10 used Iliffe vectors, since that made array addressing almost trivial given the PDP-10's multi-level index+indirect modes in memory-reference instructions. If a, b, & c were already in the proper registers, "foo[a,b,c] := foo[a,b,c] + 1" could be done in *one* instruction!! (No joke.)
-Rob
----- Rob Warnock, PP-ASEL-IA <r...@rpw3.org> 627 26th Avenue <URL:http://www.rpw3.org/> San Mateo, CA 94403 (650)572-2607
Joseph Dale <jdale1...@sbcglobal.net> wrote: +--------------- | "The straight dope" is a term, and I understand it to mean "the real | information, without any lies or BS". +---------------
Something like that.
+--------------- | This is likely to be derived from the drug context, where | "straight dope" would refer to pure, unadultered material. +---------------
Sorry, "dope" as "(reliable) information" long pre-dates the current drug sub-culture. Check out any WW2-era movie for some then-current usage, e.g., "Hey, Joe, did you talk to Sarge? What's the dope on our mission?
+--------------- | Which could be rephrased, mixing in the semiconductor metaphor, | as "dope with no dope". +---------------
Probably not. The semiconductor metaphor indeed probably derives from the *medical* [though not originally "druggie"] slang for medication (e.g., "Has he been doped yet?"), but "dope vectors" comes from the earlier, pure meaning of "information".
-Rob
----- Rob Warnock, PP-ASEL-IA <r...@rpw3.org> 627 26th Avenue <URL:http://www.rpw3.org/> San Mateo, CA 94403 (650)572-2607
Rob Warnock wrote: > Joseph Dale <jdale1...@sbcglobal.net> wrote: > +--------------- > | This is likely to be derived from the drug context, where > | "straight dope" would refer to pure, unadultered material. > +---------------
> Sorry, "dope" as "(reliable) information" long pre-dates the > current drug sub-culture. Check out any WW2-era movie for some > then-current usage, e.g., "Hey, Joe, did you talk to Sarge? > What's the dope on our mission?
Actually, OED dates the drug/medical usage of "dope" back to the 1870s/80s -- for example, in the context of opium, whose drug subculture probably has an even longer history than that just in America, let alone in other English-speaking nations and colonies. On the other hand, no references for the "information" usage appear before the 1900s.
Tim Bradshaw <t...@cley.com> writes: > Isn't there a term in some US slang `the straight dope'? I'm not sure > what it means (or if it is a term in fact), but I think it's something > to do with getting information about something, which would explain te > `dope vector' usage.
It's also the name of Cecil Adam's syndicated column and website, on approximately that subject: http://www.straightdope.com/
This is, strictly speaking, off-topic for cll, but it's hard not to feel some kind of sympathetic resonance with a web site describing itself as "Fighting ignorance since 1973 (it's taking longer than we thought)"
Joseph Dale <jdale1...@sbcglobal.net> writes: > Rob Warnock wrote: > > Joseph Dale <jdale1...@sbcglobal.net> wrote: > > +--------------- > > | This is likely to be derived from the drug context, where > > | "straight dope" would refer to pure, unadultered material. > > +--------------- > > Sorry, "dope" as "(reliable) information" long pre-dates the
> > current drug sub-culture. Check out any WW2-era movie for some > > then-current usage, e.g., "Hey, Joe, did you talk to Sarge? > > What's the dope on our mission?
> Actually, OED dates the drug/medical usage of "dope" back to the > 1870s/80s -- for example, in the context of opium, whose drug > subculture probably has an even longer history than that just in > America, let alone in other English-speaking nations and colonies. On > the other hand, no references for the "information" usage appear > before the 1900s.
Perhaps all of these definitions are related to or derived from (or derive) the 4th definition my own dictionary gives for "dope":
"oil, grease, or fuel additive, used to make machinery run smoothly"
To get somewhat back on-topic, I view (without authority) this above definition as being the more likely derivation for a "dope vector".