[ 3 / biz / cgl / ck / diy / fa / g / ic / jp / lit / sci / tg / vr ] [ index / top / reports / report a bug ] [ 4plebs / archived.moe / rbt ]

If you can see this message, the SSL certificate expiration has been fixed.
Become a Patron!

/g/ - Technology


View post   

[ Toggle deleted replies ]
>> No.70933081 [View]
File: 100 KB, 512x256, nimlang.png [View same] [iqdb] [saucenao] [google] [report]

No, that would be Nim.

>> No.69943425 [View]
File: 100 KB, 512x256, 1500653441727[1].png [View same] [iqdb] [saucenao] [google] [report]

its a Nim thread now

>> No.65071144 [View]
File: 100 KB, 512x256, nim.png [View same] [iqdb] [saucenao] [google] [report]

Implemented a structural typing proof of concept: https://pastebin.com/egdKJMZP
It's used like this:
Vec2 = tuple[x, y: float]

Box = ref object
pos: Vec2
vel: Vec2

Circle = ref object
vel: Vec2
pos: Vec2
rad: float

Turtle = ref object
speed: float

structural(Kinetic, IKinetic):
pos: Vec2
vel: Vec2

var s: seq[IKinetic] = @[]

proc test(kin: IKinetic) =
echo kin.pos
echo kin.vel

var box = Box(pos: (1.0, 2.0), vel: (3.0, 4.0))
var circ = Circle(pos: (30.0, 40.0), vel: (50.0, 60.0), rad: 100.0)
var turtle = Turtle(speed: 0)

#test(turtle) <- gives a type error because the turtle isn't Kinetic enough

Now anything that has the appropriate fields can be passed to any function accepting an IKinetic.

>> No.64971512 [View]
File: 100 KB, 512x256, nim.png [View same] [iqdb] [saucenao] [google] [report]

>tuples with named fields
At first I thought it was unnecessary autism, but I've actually found a good use for it: different modules can have their own definitions of a vector type under different names and expose an interface that relies on it, and yet they're all perfectly compatible with eachother without requiring a shared dependency on some vector module.

>> No.64769886 [View]
File: 100 KB, 512x256, nim.png [View same] [iqdb] [saucenao] [google] [report]

So what do you fellas use to program in Nim?

>> No.64705596 [View]
File: 100 KB, 512x256, nim.png [View same] [iqdb] [saucenao] [google] [report]

How can you be aware of the existence of Lisp and still get metaprogramming so wrong? Did Andreas Rumpf forget to read his SICP? Nim metaprogramming makes me want to gouge my eyes out.

>> No.64683960 [View]
File: 100 KB, 512x256, nim.png [View same] [iqdb] [saucenao] [google] [report]

How do I inspect the fields of a type in Nim? I'm guessing it has something to do with typedesc, but the manual barely mentions it, and doesn't show how to peek inside it.

>> No.64667553 [View]
File: 100 KB, 512x256, nim.png [View same] [iqdb] [saucenao] [google] [report]

What is wrong with Nim? Why can't I get a reference to a stack-allocated object?
Foo = object
x: int

proc initFooRef(foo: ref Foo) =
foo.x = 123

var foo = Foo(x: 555)

>inb4 use var
>inb4 use ref object

>> No.61491185 [View]
File: 100 KB, 512x256, logo-withBackground.png [View same] [iqdb] [saucenao] [google] [report]

hey /g/
a couple of days ago i asked you about your opinions on rust for professional use and i got a lot of negative views so i started looking for some more non mainstream languages and stumbled upon nim, and so far i like it.
my question is can nim make it into the mainstream, and big companies?

>> No.57000716 [View]
File: 100 KB, 512x256, sfdhghjmgfndgsdgn.png [View same] [iqdb] [saucenao] [google] [report]

is nim a memelang? how can it hope to compete with the likes of ruby and python with a logo like this? baka

View posts [+24] [+48] [+96]