Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Oct 06 23:30
    lbguilherme synchronize #12571
  • Oct 06 23:25
    Blacksmoke16 labeled #12573
  • Oct 06 23:19
    robacarp labeled #12573
  • Oct 06 23:19
    robacarp opened #12573
  • Oct 06 22:34
    lbguilherme synchronize #12571
  • Oct 06 20:14
    beta-ziliani closed #12568
  • Oct 06 19:59
    beta-ziliani synchronize #12568
  • Oct 06 19:31
    lbguilherme synchronize #12571
  • Oct 06 19:09
    asterite synchronize #12524
  • Oct 06 18:52
    straight-shoota labeled #12572
  • Oct 06 18:43
    asterite synchronize #12524
  • Oct 06 17:29
    Blacksmoke16 labeled #12572
  • Oct 06 17:29
    Blacksmoke16 labeled #12572
  • Oct 06 17:04
    lbguilherme opened #12572
  • Oct 06 16:46
    lbguilherme synchronize #12571
  • Oct 06 16:14
    straight-shoota milestoned #12541
  • Oct 06 16:14
    straight-shoota milestoned #12541
  • Oct 06 14:56
    straight-shoota synchronize #11597
  • Oct 06 13:50
    lbguilherme synchronize #12571
  • Oct 06 13:45
    lbguilherme synchronize #12571
moe
@moe:busyloop.net
[m]
yeh, those i already got covered. in the renderer for an exception type you can declare whether it should automatically be injected into the swagger docs for all endpoints (useful for all the base-exceptions that can happen on any endpoint). and endpoints can declare the additional exceptions that they may throw (no way to discover them otherwise).
actually happy with how that part looks. thought that would be the harder one, but turns out the return types is actually more tricky as it fans out into return-type(s) -> renderer -> content-types.
getting that stuff to work at runtime was surprisingly easy (yay for crystal!). now discovering it before runtime to build those swagger docs. uff.
George Dietrich
@Blacksmoke16
i just made them required in athena, for diff reasons but the point is the same
not super familiar with swagger, but i know they have a concept of models of which you'd use to represent the response yea? then from there is prob a way to show how they are rendered given various content types?
i.e. the core type of the response doesnt change, just its representation
serialized representation that is
moe
@moe:busyloop.net
[m]

ha, yea, you're pointing right at the hard part.
at first i had the models generate their swagger-schema.

but then i realized, endpoints often only return a partial view of a model
(i.e. you don't want to include the password-field with users and don't want
that mentioned in the swagger-docs either).

so... it's kinda annoying, i guess my renderers (aka serializers)
have to be aware both of their model and the endpoint.

maybe it's just not solvable without really forcing the user
to explicitly declare it...

George Dietrich
@Blacksmoke16
prob a good idea to have a separate object used to represent payload/responses versus assuming that is going to match the DB model 1:1
crystal stdlib and some shards have the ability to like exclude serializing the password on serialize but accept it on deserialize, but DTO would be a more robust way to go about that imo
esp for more complex models so that the structure of the request doesnt need to be tightly coupled to the db schema
moe
@moe:busyloop.net
[m]
yea, rails has ActiveModelSerializer for this. guess i may just want too much ("just return whatever you want, we'll render & auto-doc it").
works fine up to the point of auto-doc'ing & validating the input parameters. but the return value, that's really a tough cookie.
George Dietrich
@Blacksmoke16
ultimately you'd need to define what those validations are somewhere
using a DTO for that would get you that + the structure of the request
and have another for the response that describes the response
moe
@moe:busyloop.net
[m]
yup. i'll dig more into it in the coming days.
George Dietrich
@Blacksmoke16
could use the validation component for that ;)
but sounds good :+1:
Hayden Jones
@wrq
does crystal having anything like timeit for python? I've never profiled before, but I'm trying to determine where to use Structs and where to use tuples and such in a large data model, and I was hoping to put together numbers for the performance of each design
George Dietrich
@Blacksmoke16
structs and tuples are both on the stack so they'd be essentially the same. Is suggested to use structs over tuples/namedtuples majority of the time anyway
Hayden Jones
@wrq
okay, that makes sense
thank you
George Dietrich
@Blacksmoke16
but to answer your question, i'd checkout https://crystal-lang.org/api/master/Benchmark.html
Hayden Jones
@wrq
AH, okay. I'm embarrassed that I missed that, what an obvious name for it
jwaldrip
@jwaldrip:matrix.org
[m]
Is 1.4 dropping today?
I saw the release nodes reference todays date
George Dietrich
@Blacksmoke16
sure looks like it, or if not very soon
jwaldrip
@jwaldrip:matrix.org
[m]
Does the new version still require a compile time flag to get the interpreter?
Or is it enabled by default now?
George Dietrich
@Blacksmoke16
still need to manually build it with the flag
Hayden Jones
@wrq

I want to implement something like a dispatch table for a series of pseudo-bytecode instructions. I'd like to lookup each instruction and then yield my little VM to a proc, and execute each instruction that way.

Is this wise? And also, I don't see a yield_self method, am I missing something crucial?

Hayden Jones
@wrq
oh, that's wonderful. thanks again. I swear I actually can read, I guess I just overlook all the good stuff!
George Dietrich
@Blacksmoke16
iirc there are some issues with tho
so debatable if its worth just not declaring a block arg
but if it works fine for your use case :+1:
Hayden Jones
@wrq
Do you think it makes more sense then to just implement all the bytecodes as methods under the main VM class? I had already thought of that, but it just seemed inelegant. I haven't worked with a statically typed language before, so I don't really have the right intuition for this sort of thing. If it were ruby, I would just have the VM object be very simple and then have a big hash of procs as the values and use yield_self to execute them by passing in the vm object
George Dietrich
@Blacksmoke16
Got some example code?
doesn't compile, just a quick example I crapped out
I'm writing my own Push interpreter
but that's the general idea for execution
From IRC (bridge bot)
@FromIRC
<riza> @wrq it seems like a good use of a macro to generate a dispatch method based off of some classes or methods
<riza> i suppose it depends on how many instructions are in your instruction set
Hayden Jones
@wrq
I've been dreading learning macros, but that's because I'm lazy
George Dietrich
@Blacksmoke16
any reason to not just have them as methods on vm versus passing that in?
would have to benchmark what would be more performant, but i imagine having methods on the same type would be than a bunch of procs