by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Mar 03 2017 15:52
    @dom96 banned @Octopoda7
  • Feb 12 2017 23:57
    @dom96 banned @zzz125
  • Dec 23 2016 19:43
    @dom96 banned @Izrab
Vindaar
@Vindaar
Oh, I only just realized that you're trying to access the field of the type and not of the specific instance in the latter part. No idea if that should work.
Kaushal Modi
@kaushalmodi
but TupleType.FieldName works..
we are just check if a field exists.. doing type.field is meaningless otherwise
Vindaar
@Vindaar
Well, the compilation error for that is Error: no generic parameters allowed for Person, which sort of makes sense I guess, since it's the same syntax you'd use for generics
Kaushal Modi
@kaushalmodi
hmm, makes sense
so it just happens that the square brackets are generics syntax, else it would have worked
are purely numerical generics possible?
I mean, can a type be just a number?
From IRC (bridge bot)
@FromIRC
<TheLemonMan> static[T] to the rescue
Kaushal Modi
@kaushalmodi
@Vindaar On the flip side, just Person.age (from that above example) error too nim_src_YckhwY.nim(8, 12) Error: type mismatch: got <type int>
but echo compiles(Person.age) returns true
as expected
TheLemonMan: I didn't understand how static[T] can be used here
From IRC (bridge bot)
@FromIRC
<TheLemonMan> you asked "I mean, can a type be just a number"
Vindaar
@Vindaar
Person.age simply returns the type of Person. So the error in your case is that you're doing something with it that doesn't work for a type (I guess you just removed the compiles around it?)
of age in Person I meant
So if you import typetraits it should now echo int
Kaushal Modi
@kaushalmodi
TheLemonMan: ah, OK. I meant something like Option[123] would never be valid, right?
@Vindaar ah, OK to you too :)
so the problem is that the generic parsing kicks on, on seeing Person[0] instead of returing the type of Person[0]
Vindaar
@Vindaar

what TheLemonMan was referring to is

type
  Person2[N: static[int]] = tuple
    name: string
    ages: array[N, int]

let person2: Person2[2] = ("Peter", [1, 2])
echo person2

so yes, soemthing like that is allowed

Kaushal Modi
@kaushalmodi
pretty neat
thanks!
Vindaar
@Vindaar
:)
Kaushal Modi
@kaushalmodi
type
  Person[N: static[int]] = tuple
    name: string
    childrenAges: array[N, int]

let 
  p0: Person[0] = ("Peter", [])
  p1: Person[1] = ("Peter", [1])
  p2: Person[2] = ("Peter", [1, 2])
  p3: Person[3] = ("Peter", [1, 2, 3])
echo p0
echo p1
echo p2
echo p3
:)
From IRC (bridge bot)
@FromIRC
<FromDiscord> <Shield> how do I make nim generate readable assembly code?
<Araq> --lineDir:on and pass some flags to gcc/clang that keep the produced asm
<Araq> I can never remember what that switch is called, -S ?
Clyybber
@Clyybber
@rayman22201 It certainly does look interesting. It also doesn't claim to have "innovative" features, though I think the term rewriting is an interesting approach to what is essentially a macro.
From IRC (bridge bot)
@FromIRC
<TheLemonMan> @dom96, ping
<FromDiscord> <Shield> where is the asm kept? I didn't find it in nimcache
Mamy Ratsimbazafy
@mratsim
in the .o objects in nimcache
but you should take the .c files in nimcache copy paste the gcc command that was used to produce them and add -S
From IRC (bridge bot)
@FromIRC
<Araq> no, you can use --passC:"-S"
<FromDiscord> <Shield> it worked, thanks!
Rubi
@codenoid
hi
i want ask something about algorithm

total_post = 8
total_post_per_page = 5

ex : total_post = 8 == 2 page

ex : total_post = 14 == 3 page

how to find total page by total_post and total_post_per_page

i'm bad at math xD
i was think about
total_post/total_post_per_page # -> to even, ex 8/5 1.6 > 2 (2 page)
From IRC (bridge bot)
@FromIRC
<TheLemonMan> pages = (posts / posts_per_page) + 1
dm1try
@dm1try

ex : total_post = 10 == 2 page

Rubi
@codenoid
yes like that @dm1try
Vindaar
@Vindaar
@codenoid, @dm1try refers to the fact that TheLemonMan's formula breaks for 10 posts. I'd go with let pages = ceil(posts / posts_per_page)
maybe convert back to int if that's what you need
dm1try
@dm1try
winner^
Rubi
@codenoid
yeah
math.ceil is what i need (in python)
:sparkles: thankyou
Kaushal Modi
@kaushalmodi
what? You are asking solutions for problems writing python code in nim forum? :P
vivek poddar
@vivekimsit

I am trying to include the side effect pragma {.noSideEffect.} to functional but I am getting error:

https://github.com/vivekimsit/pretty-bytes/blob/master/src/prettybytes.nim#L10

Error: