ChanServ changed the topic of #crystal-lang to: The Crystal programming language | | Fund Crystal's development: | GH: | Docs: | Gitter:
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
mattt1 has joined #crystal-lang
mattt has quit [Ping timeout: 276 seconds]
void09 has joined #crystal-lang
<FromGitter> <> Heya. Is there anyway to export crystal classes into Python?
<FromGitter> <Blacksmoke16> no
<FromGitter> <> Can't Crystal export any bindings?
<FromGitter> <> Oh, this was a short answer. :) Anyway, it seems crystal classes can be exported into ruby.
<FromGitter> <Blacksmoke16> in some cases yes, but usually no
<FromGitter> <> But why?
<FromGitter> <Blacksmoke16> ```class Foo ⏎ def run ⏎ "foo" ⏎ end ⏎ end``` ⏎ ⏎ is valid Ruby and Crystal []
<FromGitter> <Blacksmoke16> but once you start adding type restrictions to things like: ⏎ ⏎ ```class Foo ⏎ def run : String ⏎ "foo" ⏎ end ⏎ end``` ⏎ ⏎ This is only valid Crystal []
<FromGitter> <Blacksmoke16> because Ruby doesn't have that concept, so would be invalid Ruby syntax
<FromGitter> <Blacksmoke16> but by export i assume you mean copy/paste?
<FromGitter> <> Oh, I mean the binding between this languages.
<FromGitter> <Blacksmoke16> officially Crystal only supports C bindings afaik
<FromGitter> <> How about this project?
<FromGitter> <Blacksmoke16> i didnt say it was impossible, just that it's not an official feature of the lang. I.e. not built-in
<FromGitter> <Blacksmoke16> if there's a shard to do what you're wanting, that's great
<FromGitter> <> Good luck trying to embed CPython :)
<FromGitter> <> Oh, thanks anyway :) I would like to call Crystal methods from python.
<FromGitter> <Blacksmoke16> good luck ;P
<FromGitter> <> However will be simpler probably with pypy or other alternative interpreters
<FromGitter> <Blacksmoke16> any reason you cant just use Crystal for everything? 😉
<FromGitter> <> Would be too simple haha 😂
<FromGitter> <> At least use Ruby :3
<FromGitter> <> You can make a crystal server and send RPCs to it from python or ruby
<FromGitter> <> That'a good solution, I've done this with JavaScript <-> Crystal
<FromGitter> <> Though it's best to auto generate message classes for both ends to avoid any errors
<FromGitter> <> grpc may be useful but I've never tried it with crystal
<FromGitter> <> Does someone have an idea of what's going on here?
<FromGitter> <Blacksmoke16> i think the interface expects there not to be any yielded args, while your implementation has 1
<FromGitter> <> I see, strange:
<FromGitter> <> Remove the `self.` before the `a.`, still error.
<FromGitter> <> Strange that module are less strict than class/structs
<FromGitter> <Blacksmoke16> well for one you cant have abstract class methods
<FromGitter> <> yeah I know, but error still there in any case
<FromGitter> <> ha ok for modules
<FromGitter> <Blacksmoke16>
<FromGitter> <> I should use ectend, forgot it
<FromGitter> <> interfaces are really not ideal :/
<FromGitter> <Blacksmoke16> depends on the use case
<FromGitter> <> If you want an interface which for class and instance methods, it becomes messy
<FromGitter> <Blacksmoke16> could have macro included hook on the interface that extends another class interface module :shrug:
<FromGitter> <> probably... the API docs won't be as clear "Take case to also implement methods in X"
<FromGitter> <> generics can also be used to some extent
<FromGitter> <Blacksmoke16> related
<FromGitter> <> Thanks!
ur5us has joined #crystal-lang