Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Cedric Hutchings
@cedric-h
I use Phys as a handle to a certain physics body
you can't move anything with phys alone, since all of the physics information is stored in the PhysState resource
Brendan Zabarauskas
@brendanzab
yeah, that's fine. In purely functional programming it's ok to think in imperative terms. You can gradually move to pushing your imperative stuff to the boundaries of your application (as you get more comfortable with FP)
Cedric Hutchings
@cedric-h
(PhysState holds an nphysics3d world)
so you use the entity of the player to get the corresponding Phys component from the specs world, then you use the specs world again to get the PhysState. Then, you tell the PhysState to move the body this Phys component corresponds to to this location
I have no idea how I'm going to represent any of that in FP, though
I can call Rust functions from Gluon
could that Rust function mutate the world?
essentially, can Rust functions called from Gluon break FP rules?
Brendan Zabarauskas
@brendanzab
You'd have to say that 'this thing does an effect'
Cedric Hutchings
@cedric-h
hm
Brendan Zabarauskas
@brendanzab
either by using some monad, putting it in the IO type, or using the newer effect system stuff
but I there may or may not be an example of that yet
Cedric Hutchings
@cedric-h
"Extending the guessing game" is an example of it
let on_interaction interactor = 
    teleport interactor 0 0 0
this is what I was envisioning before I realized how different FP was
now I still don't really understand but I picture
Brendan Zabarauskas
@brendanzab
the advantage of using the effect system is that you can have multiple effects that compose together - like the 'physics world effect' or the 'specs world' effect, without having to shuffle them around in an annoying way
Cedric Hutchings
@cedric-h
let on_interaction interactor = 
    do _ = teleport interactor 0 0 0
lol
Brendan Zabarauskas
@brendanzab
Anyway, I've gotta get back to work, but I hope that helps a little
Cedric Hutchings
@cedric-h
yeah, thanks
Brendan Zabarauskas
@brendanzab
At least until Marwes can come and make it more concrete for you
Cedric Hutchings
@cedric-h
the physics world is theoretically stored within the specs world, so... only one State to manage?
Brendan Zabarauskas
@brendanzab
Possibly! You could start off that way.
Markus Westerlind
@Marwes

how can I have it mutate something I send it, though?

You may want to look at https://github.com/gluon-lang/gluon/pull/716/files#diff-fdf9790a6fe2177d1469db998fc15556R488 . It makes the functions work in the IO monad but that could techincally be omitted since gluon does not assume anything about purity (that might change though)

I am working towards letting one define a custom effect which could take such a mutable reference on which arbitrary (effectful) functions could be defined. Then purity could be retained on the gluon side without needing to contort the rust side
Markus Westerlind
@Marwes

could that Rust function mutate the world?
essentially, can Rust functions called from Gluon break FP rules?

While FP encourages pure code it is not a requirement. Ocaml for instance have objects with mutable fields and mutable references

Cedric Hutchings
@cedric-h
hm
jakbyte
@jakbyte
What are gluon's forms of structs, traits, and enums?
jakbyte
@jakbyte
Thanks!
eldyer
@eldyer
Hi! I'm trying to do something like this:
#[derive(Debug, Userdata, Trace)]
struct GluonEntity(specs::Entity);
which doesn't work, because the Trace trait can't be derived automatically in this case
So how can I implement it manually? couldn't find any docs about this ...
eldyer
@eldyer
I don't know what I'm doing, but with #[gluon_trace(skip)] it just seems to work :pray:
Markus Westerlind
@Marwes
Yeah, that is how it is supposed to be done for types which do not contain any gc references
eldyer
@eldyer
okay!
eldyer
@eldyer
When using add_extern_module and importing that module in a .glu file, the LSP says it can't find the module (although the code runs). Is there some trick to satisfy the LSP?
Markus Westerlind
@Marwes
LSP = Language server protocol?
eldyer
@eldyer
yes
the vscode client actually
Markus Westerlind
@Marwes
That does not work atm, the language server runs its own instance of the gluon interpreter
eldyer
@eldyer
oh, ok!
Markus Westerlind
@Marwes
So any rust modules will not be detected through it
I would like to add a feature where you can dump any rust modules you have to a file which the language server can then pick up
eldyer
@eldyer
that would be great :+1:
eldyer
@eldyer
in Ocaml, you can omit the else part in an if-then-else expression, if the first part returns a unit type ... have you considered this for gluon?
Markus Westerlind
@Marwes
No, since gluon is pure that isn't really useful
eldyer
@eldyer
ah, makes sense