lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Hi, list

Why does not replace the return value type(i.e. GCobject*) of
luaC_newobj() function with the type of union GCunion* to avoid
calling the explicit cast(i.e. gco2t, gco2p, gco2u and etc.) and make
the code more concise?

It's likely that there are some aspects where I have not kept pace.
So please let me know if I missed something.

Here are some related code snippets:
Table *luaH_new (lua_State *L)
  GCObject *o = luaC_newobj(L, LUA_VTABLE, sizeof(Table));
  Table *t = gco2t(o);

CClosure *luaF_newCclosure (lua_State *L, int nupvals)
  GCObject *o = luaC_newobj(L, LUA_VCCL, sizeCclosure(nupvals));
  CClosure *c = gco2ccl(o);

static TString *createstrobj (lua_State *L, size_t l, int tag, unsigned int h)
  TString *ts;
  GCObject *o;
  size_t totalsize;  /* total size of TString object */
  totalsize = sizelstring(l);
  o = luaC_newobj(L, tag, totalsize);
  ts = gco2ts(o);

I would be grateful to have some help with this question.
Best regards