[ANN] fixedpnt 0.0.1: Binary Fixed Point Calculations

https://github.com/Axel2/fixedpnt.rb
Allows simulating binary fixed point calculations done in hardware.

There is another library from Phil T. which serves the same purpose
but with different properties:
http://rubyforge.org/projects/fixedpt/

For decimal fixed point calculations there is at least the library
from Karl B.:
http://rubyforge.org/projects/long-decimal/

Kind Regards,
Axel

On Mar 20, 2013, at 07:25 , Axel F. [email protected] wrote:

https://github.com/Axel2/fixedpnt.rb
Allows simulating binary fixed point calculations done in hardware.

This looks like a good start, but I’d like to suggest some changes:

  1. package it as a gem. I’d be happy to help with this.

  2. add real tests. If I help with the above, you’ll get templates for
    this.

  3. think about changing the license to ruby, mit, or bsd. gpl is
    generally discouraged in our community.

On 03/20/2013 07:25 AM, Axel F. wrote:

https://github.com/Axel2/fixedpnt.rb
Allows simulating binary fixed point calculations done in hardware.

A random api suggestion… consider using #[]= as an alias for #assign,
following this example:

class A; def []=(v); @x = v; end; def []; @x; end; end
=> nil

a = A.new
=> #<A:0x007fdf9c617438>

a[] = 3
=> 3

a[]
=> 3

a
=> #<A:0x007fdf9c617438 @x=3>

You can think of [] as a “dereference operator” for boxed values.

As a bonus, ruby gives these operators some basic assignment semantics:

y = a[] = 4
=> 4

y
=> 4

This works regardless of the actual return value of #[]=.

And:

b = A.new
=> #<A:0x007fdf9c6dee70>

b[] ||= 42
=> 42

b[]
=> 42

The line

b[] ||= 42

is roughly the same as

b[] = b[] || 42

and causes a call to #[] followed by #[]=.

Ryan D. [email protected] wrote:

  1. think about changing the license to ruby, mit, or bsd. gpl is
    generally discouraged in our community.

I encourage Axel to choose the license he feels is best.

I’ve never felt discouraged for releasing LGPL/GPL/AGPL code,
but I’d never betray my personal beliefs for popularity, either.

A random api suggestion… consider using #[]= as an alias for #assign,

I see the advantages. Only thing is, I can’t remember to have seen this
before, without any “argument” inside []. I mean, for example,
‘hello’[0] = ‘H’, has a 0 as “argument” inside []. Isn’t this syntax
(without argument) very strange or would it be seen as “good ruby”/“the
ruby way”?

Axel

On 21 March 2013 10:41, Axel F. [email protected] wrote:

The truth is, I didn’t want to bother with license. But I felt, I need
one, and GPL was one I often saw together with software. That’s the only
reason why I took GPL. - Saying, “license is same as Ruby’s”, would that
be enough? Or, can the most important advantages/disadvantages of
ruby/mit/bsd be told in a few easy sentences? I need not to have it
perfect.

One of the concerns people have with the GPL is that it is copyleft,
meaning you cannot add “restrictions” later on: any rights granted to
the software through the GPL cannot be removed in any derivatives. It
is in some sense “viral”. If you use GPL’d derived code in your work,
it cannot be proprietary and closed, it must be as free as the GPL.

In contrast, the more “permissive” licenses like MIT/BSD/ISC place
very few restrictions beyond attribution (through maintaining the
copyright notice), so that, say, MIT-licensed code can be included in
proprietary software, or the license on the code itself changed
(sublicensing). (For this reason, MIT is shorter and doesn’t require a
lot of legalese.) It turns the “keep it free” aspect into a social,
contribute-back-to-the-community issue.

You should pick whichever license covers your intent of the code. Do
you want it to be free “permanently” (GPL or another copyleft
license), or do you want to be more permissive (MIT/BSD/ISC or
similar)?

As a mini aside, you can also look at the Apache license, which
includes other clauses like assuming contributions are also under the
Apache license. Note this is different from copyleft, like the GPL.
I’d actually really like to see a license that is MIT-style + this
clause. I actually did a write-up1 of this kinda stuff, if you’re
curious, where I also looked at taking contributions and including
those in the copyright notice. Some projects have a lot of
contributions but this never gets fed back into the copyright notice,
which is a bit of a shame if there are significant contributors.

Thank you for your suggestions!

  1. package it as a gem. I’d be happy to help with this.

I’m happy to accept your help. I never built a gem before.

  1. add real tests. If I help with the above, you’ll get templates for
    this.

I’ll try to do so.

  1. think about changing the license to ruby, mit, or bsd. gpl is
    generally discouraged in our community.

The truth is, I didn’t want to bother with license. But I felt, I need
one, and GPL was one I often saw together with software. That’s the only
reason why I took GPL. - Saying, “license is same as Ruby’s”, would that
be enough? Or, can the most important advantages/disadvantages of
ruby/mit/bsd be told in a few easy sentences? I need not to have it
perfect.

Axel

On 03/21/2013 06:41 AM, Axel F. wrote:

  1. think about changing the license to ruby, mit, or bsd. gpl is
    generally discouraged in our community.

The truth is, I didn’t want to bother with license. But I felt, I need
one, and GPL was one I often saw together with software. That’s the only
reason why I took GPL. - Saying, “license is same as Ruby’s”, would that
be enough? Or, can the most important advantages/disadvantages of
ruby/mit/bsd be told in a few easy sentences? I need not to have it
perfect.

The MIT and BSD licenses basically ensure that you get attribution for
your work. If someone wants to redistribute the software themselves,
they must include your license.

The GPL does that too, but it also requires that developers who use the
library in their own work make available the source code, and make
available any changes they’ve made to the source code.

If you just want a license that ensures (1) other developers can legally
use your code for themselves and (2) you receive credit, then an MIT or
BSD license is fine.

If you’re concerned that a big faceless corporation is going to make
changes to your code that it doesn’t release to the public, then you
want the GPL.

  • Grant

https://www.rubygems-openpgp-ca.org/ Sign your gems.

A random api suggestion… consider using #[]= as an alias for #assign,


…I see no reason not to take advantage of this special
case. The ruby way is in the eye of the beholder…

I’ll implement it as alias. So me (and others?) can try out which feels
more handy.

Axel

On Mar 21, 2013, at 03:41 , Axel F. [email protected] wrote:

I’ll try to do so.
Done. I sent you a pull request a minute ago.

On 03/21/2013 03:51 AM, Axel F. wrote:

A random api suggestion… consider using #[]= as an alias for #assign,

I see the advantages. Only thing is, I can’t remember to have seen this
before, without any “argument” inside []. I mean, for example,
‘hello’[0] = ‘H’, has a 0 as “argument” inside []. Isn’t this syntax
(without argument) very strange or would it be seen as “good ruby”/“the
ruby way”?

A reasonable concern. I don’t think I’ve seen this construct (#[]= and
#[] with no args) used before either. Every other operator forces a
particular arity. I see no reason not to take advantage of this special
case. The ruby way is in the eye of the beholder…

https://github.com/Axel2/fixedpnt.rb
Allows simulating binary fixed point calculations done in hardware.

  • It’s available as gem now: fixedpnt.
  • License changed to MIT.
  • Some small changes.

Kind Regards,
Axel

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs