How to do table lookups? (fwd)

Vance Shipley vances@REDACTED
Wed Mar 3 21:30:28 CET 2004

}  > }    <<First:1/binary, Rest/binary>> = Bytes,
}  >
}  > The above will not work.  It should be:
}  >
}  >     <<First:8/binary, Rest/binary>> = Bytes,
}  I thought if you use /binary, then the default unit is 8bits, so the
}  :1/binary = :8. At least, this is how I read it in the bit syntax. Is this
}  wrong?

Doh!  I didn't see the "/binary" for some reason, probably 'cause
it's a fairly strange thing to do when you wanted an integer.  You
are correct, the default unit size of a binary is 8.

}  Actually, I was looking at the gen_server, and was having an issue with
}  regards to the receives not seeming to be able to have a guard. I have a
}  couple of programs where I do synchronization based on guard expressions
}  to implement bounded queues. While I could rewrite to not do this, it
}  would definitely not be as clean.

I'm not sure I follow you.  You can implement guards as:

handle_cast({Foo, Bar}, State) when is_integer(Bar),
	Bar < 10 ->

If you want to control the number of messages in your mailbox than
you'll just need to become an expert and implement everything you
need.  If you're new to Erlang/OTP and you find you need to do this
level of hackery again you should assume you are doing soomething

}  Back to this being somebody else's program, and so do not have an option
}  of ei.

You could alwaysd write a wrapper in C using ei.

}  Nope, OpenBSD/Linux. The program does not detect that the listening
}  program has closed the file descriptors, and so hangs on full pipes
}  without dying.

Your wrapper could solve this.


More information about the erlang-questions mailing list