Live data from Hacker News

Kamby – A programming language based on Lisp that doesn't seem like Lisp

kamby.org

1–10 of 53 posts

Re: Kamby – A programming language based on Lisp that doesn't seem like Lisp

#5
post #4

Where are the macros?

Yeah, I think the title should be updated to something less elaborative. Looks like the reference to Lisp comes from the Github Readme?

https://github.com/henriquegogo/kamby

Still looks awesome; 400LOC is an incredible achievement for grok-ability c:

Re: Kamby – A programming language based on Lisp that doesn't seem like Lisp

#6
Browsing the source code, I came across something completely unexpected. I didn't know you could put code in structs like this sample from kamby/kamby.c

  struct KaNode *ka_add(struct KaNode *node, struct KaNode **env) {
    if (node->type == KA_STR && node->next->type == KA_STR) {
      struct KaNode *output = ka_str(node->str);
      strcat(output->str, node->next->str);
      return output;
    }
    return ka_num(node->num + node->next->num);
  }
Is this legal? If so, I'm going to use the heck out of it for my version of STOIC.

[Edit] Ok.. thanks for the help.. I'm used to seeing function types declared AFTER the parameters because pascal habits die hard. It looked like a run of the mill structure declaration to me.

Re: Kamby – A programming language based on Lisp that doesn't seem like Lisp

#7

Browsing the source code, I came across something completely unexpected. I didn't know you could put code in structs like this sample from kamby/kamby.c struct KaNode *ka_add(struct KaNode *node, struct KaNode **env) { if (node->type == KA_STR && node->next->type == KA_STR) { struct KaNode *output = ka_str(node->str); strcat(output->str, node->next->str); return output; } return ka_num(node->num + node->next->num); }…

I don't really know C, but I think this is a function returning a "struct KaNode*" type, not a struct.

Re: Kamby – A programming language based on Lisp that doesn't seem like Lisp

#8

Browsing the source code, I came across something completely unexpected. I didn't know you could put code in structs like this sample from kamby/kamby.c struct KaNode *ka_add(struct KaNode *node, struct KaNode **env) { if (node->type == KA_STR && node->next->type == KA_STR) { struct KaNode *output = ka_str(node->str); strcat(output->str, node->next->str); return output; } return ka_num(node->num + node->next->num); }…

That’s a function that returns a struct. In C structs live in their own namespace and references to them have to use the struct keyword unless you define a typedef.

Re: Kamby – A programming language based on Lisp that doesn't seem like Lisp

#9

Browsing the source code, I came across something completely unexpected. I didn't know you could put code in structs like this sample from kamby/kamby.c struct KaNode *ka_add(struct KaNode *node, struct KaNode **env) { if (node->type == KA_STR && node->next->type == KA_STR) { struct KaNode *output = ka_str(node->str); strcat(output->str, node->next->str); return output; } return ka_num(node->num + node->next->num); }…

I don't do a lot of C, but isn't this just a global function returning a pointer to a KaNode? If I remember correctly this is just Cs way of specifying a type is a struct same thing with the line in your example "struct KaNode *output = ..." someone feel free to correct me if I am wrong though.
Post reply on HN